Jump to content

[SOLVED] Syntax Error


Bopo

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.