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); } ?> 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)) 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! Link to comment https://forums.phpfreaks.com/topic/150609-solved-syntax-error/#findComment-791109 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.