Zeradin Posted January 2, 2009 Share Posted January 2, 2009 It's driving me crazy. I just modified a shoutbox I made that worked and now it's not inserting the data into the tables. if(isset($_POST['shout'])) { $name = addslashes($_POST['name']); $message = addslashes($_POST['message']); $shoutquery = "INSERT INTO ybcomments (name, message, photoid) VALUES ('$name', '$message', '$id')"; $shoutresult = mysql_query($shoutquery); echo '<meta http-equiv="Refresh" content="0;url=prpyearbook.php?id='.$id.'">'; } echo '<form method="POST" action="prpyearbook.php?id='.$id.'">'; ?> <table><tr><td> <strong>Name</strong></td><td>::</td><td> <input type="text" name="name" size="15"></td> <td><strong>Message</strong></td><td>::</td><td> <input type="text" name="message" size="35"></td><td></td><td></td><td><input type="submit" value="Do It!" name="shout" class="btn" /></td><tr></table> Quote Link to comment Share on other sites More sharing options...
Zeradin Posted January 2, 2009 Author Share Posted January 2, 2009 I'm just throwing it into a table on my page, i could do an iframe or something like i had in my other site, but this should work right? Quote Link to comment Share on other sites More sharing options...
Zeradin Posted January 2, 2009 Author Share Posted January 2, 2009 anyone have an idea? Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted January 2, 2009 Share Posted January 2, 2009 For starters, try debugging the query: $shoutresult = mysql_query($shoutquery) or trigger_error(mysql_error(),E_USER_ERROR); Quote Link to comment Share on other sites More sharing options...
flyhoney Posted January 2, 2009 Share Posted January 2, 2009 I made some non vital changes, mostly formatting, you can see them below. But the only real problem I see is no closing form tag. Also the meta tag has to be in the header. I was thinking maybe you simplified the code to post it here. But maybe you did not. Also, where is $id coming from? <?php if(isset($_POST['shout'])) { $name = mysql_real_escape_string($_POST['name']); $message = mysql_real_escape_string($_POST['message']); $shoutquery = " INSERT INTO ybcomments SET name = '$name', message = '$message', photoid = '$id' "; $shoutresult = mysql_query($shoutquery); // NOTE: this has to be in the header echo '<meta http-equiv="Refresh" content="0;url=prpyearbook.php?id='.$id.'">'; } ?> <form method="POST" action="prpyearbook.php?id=<?php echo $id ?>"> <table> <tr> <td><strong>Name</strong></td> <td>::</td> <td><input type="text" name="name" size="15" /></td> <td><strong>Message</strong></td><td>::</td> <td><input type="text" name="message" size="35" /></td> <td> </td> <td> </td> <td><input type="submit" value="Do It!" name="shout" class="btn" /></td> <tr> </table> </form> Quote Link to comment Share on other sites More sharing options...
Zeradin Posted January 2, 2009 Author Share Posted January 2, 2009 The debugging worked. I'm an idiot. Thanks for getting me to look the right way. Yes I was posting partial code, id was from earlier in the page. 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.