Jump to content

Comment script has problems


dunc453

Recommended Posts

Hey

 

Any ideas why everytime someone refrshes this page after entering a comment it displays more and more of the same comment, take a look:

 

http://www.ictkix.com/dlewis/duncan.php

 

There is also the following error:

INSERT INTO Comment VALUES (NULL,'blahj','blah','blah','blah')

 

This is the php script:

<?php

echo $sql . "

";

   //create sql to query database

   //selct all records from table called: Comment

   $sql = "SELECT * FROM Comment";

   //connect to database using username and password

   $dbh=mysql_connect ("localhost", "xxxxxxx", "xxxxxxx");

   mysql_select_db ("dcraddoc_dlewis");

   //execute sql        

   $result=mysql_query($sql);

   //no. of records found

   $num=mysql_numrows($result);



   //use loop to show any records found:

   $i=0;

   while ($i < $num) {

       //get data from each record

       $id = mysql_result($result,$i,"ID");

       $Email = mysql_result($result,$i,"Email");

       $When = mysql_result($result,$i,"When");

       $Who = mysql_result($result,$i,"Who");

       $Comment = mysql_result($result,$i,"Comments");

       //display on screen, in a table:

        echo "";

       echo "$id";

       echo "$Email";

       echo "$When";

       echo "$Who";

       echo "$Comment";

        echo "";

       //increment value of $i to get next record (if any)

       $i++;    

   }

   //close database connection

   mysql_close();

?>

 

Any ideas?

Link to comment
Share on other sites

every time you refresh it resends the query and im guessing ID is auto_increment so it just creates a new record.

 

edit: as far as solving it goes, i'm afraid im not awake enough to take a proper look (and im pretty much a beginner)

Edited by ll87
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...