steve490 Posted February 26, 2010 Share Posted February 26, 2010 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.