Bopo Posted March 22, 2009 Share Posted March 22, 2009 Hi I have been staring at this code for a while, and I still can't find the syntax error: syntax error, unexpected '{' There's a comment in the code to show which line is being flagged. <?php if(isset($_POST['submit'])) { if(empty($_POST['author']) && empty($_POST['title']) && empty($_POST['category']) && empty($_POST['post'])) { die('Please fill in all required fields'); } $author = ($_POST['author']); $title = ($_POST['title']); $post = ($_POST['post']); $category = ($_POST['category']); $date = date("m.d.y"); include("blogconnect.php"); $sql = "INSERT INTO blogposts (author,title,post,category,date) VALUES ('$author', '$title', '$post', '$category', '$date')"; if(!mysql_query($sql, $connect) { //this is the line that the error is appearing on die('Error' . mysql_error()); } echo "Your post has been successfully posted"; mysql_close($connect); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/150609-solved-syntax-error/ Share on other sites More sharing options...
Philip Posted March 22, 2009 Share Posted March 22, 2009 if(!mysql_query($sql, $connect) should be if(!mysql_query($sql, $connect)) Quote Link to comment https://forums.phpfreaks.com/topic/150609-solved-syntax-error/#findComment-791108 Share on other sites More sharing options...
Bopo Posted March 22, 2009 Author Share Posted March 22, 2009 Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/150609-solved-syntax-error/#findComment-791109 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.