php comment script

hello, again. i have another question. i have a simple comment script i had found on the net and mad some changes to better fit my site. how when i past the code into a page the same comments show up. how do i get rid of this so that the post are not all the same here are my codes.

connect.php[code]

<?php $host = ''; $username = ''; $password = ''; $database = ''; mysql_connect($host, $username, $password) or die("Could not connect to MySQL. Please check if all the login information is correct."); mysql_select_db($database) or die("Could not find Database. Please check if the database information is correct."); ?>

[/code]

Commentsystem folder addcomment.php[code]

<?php include_once("../connect.php"); function cleanText($text) { $text = str_replace("\\", "\\\\", $text); $text = str_replace("&", "&", $text); $text = str_replace("<", "<", $text); $text = str_replace(">", ">", $text); $text = str_replace("\"", """, $text); $text = str_replace(" ", " ", $text); $text = str_replace("\n", "
", $text); $text = str_replace("'", "''", $text); return $text; } $msg_title = cleanText($_POST['msg_tital']); $msg_message = cleanText($_POST['msg_message']); $msg_submit = $_POST['msg_submit']; if ($msg_submit && $msg_title && $msg_message) { mysql_query ("INSERT INTO comments VALUES ('','".$msg_tital."','".$msg_message."')"); } header("location:../commentsystem/"); ?>[/code]

index.php[code]

<?php include_once ( "../connect.php"); $commenting_form = '
ADD COMMENT
Tital
message
'; $get_comments = mysql_query("SELECT * FROM comments"); $comments_counts = mysql_num_rows ($get_comments); if ($comments_counts>0) { While ($com = mysql_fetch_array($get_comments)) { $id = $com ["id"]; $text = $com ["text"]; $message = $com ["message"]; $comments .= "".$text."
" .$message. "
"; } $comments.= $commenting_form; } else { $comment = "There are no comments at this time "; } ?> Untitled Document <?php echo $comments;

?>

[/code]

If this is a comment script it is supposed to add comments to a page, what exactly do you want to get rid of?

sorry i wasn’t that clear, just noticed i rambled must of that. i place the code in the spot of the website i want it to be desplayed, and all my info pops up, that is the info in the database. however i would like to place comments on many paged and i dont want the same info showing up on all the pages. i would like to know how to fix this issue. again thanks for the help.

You will need to add new field to the comments database table - page id. This field will be used when you’re recording comments to table, and when you query comments to display on each page. So you will need to modify comment script too.

ok great thanks for the heads up-- i just noticed a second prob. i placed my code into the website review.php where i want the comment box to be. now on the doc i made for the comment system everything works fine. the above scripts is what im talking about…i placed the code in the index.php file into my review.php file and when you submit a comment it will not work.

Sponsor our Newsletter | Privacy Policy | Terms of Service