Guest Posted July 2, 2008 Share Posted July 2, 2008 I have a form on my website that looks like this... <form action="newComment.php?postId=<?php echo $postId; ?>" method="post"> When it gets to the newComment.php, it's supposed to redirect the user back to post.php if they forgot to fill in a required field on the form... if (empty($_POST['title']) || empty($_POST['author']) || empty($_POST['content'])) { header("Location: post.php?id=$postId"); It successfully send the user back, but I get a MySQL query error here... $postId = $_GET['id']; $postQuery = "SELECT title, author, datetime, content, blog, tags FROM posts WHERE id = $postId"; $postResult = mysql_query($postQuery); list($postTitle, $postAuthor, $postDatetime, $postContent, $postBlog, $postTags) = mysql_fetch_row($postResult); The error says that $postResult is not a valid MySQL resource. Is there something wrong with my header() function? This is extremely frustrating. Can anyone help? Link to comment https://forums.phpfreaks.com/topic/112874-solved-tricky-forms/ Share on other sites More sharing options...
trq Posted July 2, 2008 Share Posted July 2, 2008 In your call to header(), where is $postId defined? Link to comment https://forums.phpfreaks.com/topic/112874-solved-tricky-forms/#findComment-579755 Share on other sites More sharing options...
Guest Posted July 2, 2008 Share Posted July 2, 2008 Doh! I was using $postId = $_POST['postId'] instead of $_GET['postId']. Silly me. Link to comment https://forums.phpfreaks.com/topic/112874-solved-tricky-forms/#findComment-579757 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.