Current location: Hot Scripts Forums » Programming Languages » PHP » post comments


post comments

Reply
  #1 (permalink)  
Old 07-29-10, 12:07 AM
williamh26 williamh26 is offline
Wannabe Coder
 
Join Date: Jul 2010
Posts: 122
Thanks: 2
Thanked 0 Times in 0 Posts
post comments

I have this code: to add a comments
PHP Code:

<?php

     $prodid 
$_GET['id'];

  
mysql_connect($host,$user,$password); // connect to mysql server //
mysql_select_db($db);

 
$query "SELECT count(commentid) from comments where prodid = $prodid";
$result mysql_query($query);
$row=mysql_fetch_array($result);
if (
$row[0] == 0)
{
   echo 
"Add your comments about this Drug. \n";
   echo
"<p>\n";
   echo 
"No comments posted yet.  \n";
   echo 
"<a href=\"index.php?content=newcomment&id=$prodid\">Add a comment</a>\n";
   echo 
"   <a href=\"print.php?id=$prodid\" target=\"_blank\">Print Details</a>\n";
   echo 
"<hr>\n";
} else
{
   
$totrecords $row[0];
   echo 
$row[0] . "\n";
   echo 
" comments posted.  \n";
   echo 
"<a href=\"index.php?content=newcomment&id=$prodid\">Add a comment</a>\n";
   echo 
"   <a href=\"print.php?id=$prodid\" target=\"_blank\">Print Details</a>\n";
   echo 
"<hr>\n";
   echo 
"<h6>Comments:</h6>\n";

   if (!isset(
$_GET['page']))
      
$thispage 1;
   else
      
$thispage $_GET['page'];

   
$recordsperpage 2;
   
$offset = ($thispage 1) * $recordsperpage;
   
$totpages ceil($totrecords $recordsperpage);

   
$query "SELECT date,poster,comment from comments where prodid = $prodid order by commentid desc limit $offset,$recordsperpage";
   
$result mysql_query($query) or die('Could not retrieve comments: ' mysql_error());
   while(
$row mysql_fetch_array($resultMYSQL_ASSOC))
   {
       
$date $row['date'];
       
$poster $row['poster'];
       
$comment $row['comment'];
       
$comment nl2br($comment);

       echo 
$date " - posted by " $poster "\n";
       echo 
"<br>\n";
       echo 
$comment "\n";
       echo 
"<br><br>\n";
   }

   if (
$thispage 1)
   {
      
$page $thispage 1;
      
$prevpage "<a href=\"index.php?content=showprod&id=$prodid&page=$page\">Prev</a>";
   } else
   {
      
$prevpage " ";
   }

   if (
$totpages 1)
   {
      
$bar '';
      for(
$page 1$page <= $totpages$page++)
      {
         if (
$page == $thispage)
         {
            
$bar .= $page ";
         } else
         {
            
$bar .= " <a href=\"index.php?content=showprod&id=$prodid&page=$page\">$page</a> ";
         }
      }
   }

   if (
$thispage $totpages)
   {
      
$page $thispage 1;
      
$nextpage " <a href=\"index.php?content=showprod&id=$prodid&page=$page\">Next</a>";
   } else
   {
      
$nextpage " ";
   }

   echo 
"GoTo: " $prevpage $bar $nextpage;
}
?>
However i have this error message
Warning: include(showprod.inc.php) [function.include]: failed to open stream: No such file or directory in C:\wamp\www\Rite Aid\index.php on line 198

Warning: include() [function.include]: Failed opening 'showprod.inc.php' for inclusion (include_path='.;C:\php5\pear') in C:\wamp\www\Rite Aid\index.php on line 198


i checked all the files and there are in the correct file can anyone help me please

Last edited by Nico; 07-29-10 at 03:43 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 07-29-10, 03:47 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,074
Thanks: 11
Thanked 88 Times in 83 Posts
I didn't count the lines, but I think it's save to say that your code does not have 198. Meaning, the code you posted has nothing to do with the error you posted.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 07-29-10, 06:36 PM
williamh26 williamh26 is offline
Wannabe Coder
 
Join Date: Jul 2010
Posts: 122
Thanks: 2
Thanked 0 Times in 0 Posts
commests

i fixed the script
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Login system w/ user rating + comments Anetra Script Requests 0 04-06-06 08:35 PM
Post Exchange lovely Traffic Exchange 0 11-17-05 04:03 AM
looking for comments system orang3 Script Requests 2 03-22-05 10:32 AM
New VB3 forum look, please post comments, suggestions.... phpnull.com radicalv.com Website Reviews 3 03-22-04 02:34 PM


All times are GMT -5. The time now is 11:40 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.