Jump to content

Comment box problem


steve490

Recommended Posts

Hey guys,

 

I have a gallery of photos and im using the 'GET' method to view each large picture, I created a comment box to use with each picture but when a user posts a comment the image disappears but it shows the comment. The comment is inserted into the database but without the image ID so when I go to view the image it shows an empty box. Also when ever the page is refreshed or viewed an empty comment is inserted... hope its clear, heres all the code:-


$dbname = '***';
mysql_select_db($dbname);


if (isset ($_GET['id']))
{

$imgid = $_GET['id'];

}

$image_viewer = "SELECT * FROM img WHERE imgid='$imgid'";


$show_image = mysql_query($image_viewer);

mysql_close($conn);

$email = $_SESSION['email'];
$thread = $_POST{"thread"};
$date = date("H:i jS F Y"); 

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');

$dbname2 = '****';
mysql_select_db($dbname2);

$comment_saver = "INSERT INTO threads (imageid, email, thread, timestamp) VALUES  ('".$imgid."','".$email."','".$thread."','".$date."')";


$comment = mysql_query($comment_saver);

$sql = "SELECT * FROM threads WHERE imageid='$imgid'"; 

$result = mysql_query($sql) or die(mysql_error()); 


 

The html

 


<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> 
<fieldset> 
<legend>Comment Box</legend><p> 

Have a thought... write it here:<br><textarea cols="60" rows="5" name="thread"></textarea><br>
		<input type="submit" value="Post Comment">

		</form>


	<?php

	while ($row = mysql_fetch_array($result)) { 
  
    echo "Posted by: " .$email. "<br /> ";
    echo " On " . $date . "<br /> "; 
    echo "Comment: " . $thread . "\n" . "<br /> "."<br /> ";  

	}?>

	</div>

 

Cheers... need any more info let me know

Link to comment
https://forums.phpfreaks.com/topic/193448-comment-box-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.