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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • 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.