pinochio Posted September 29, 2009 Share Posted September 29, 2009 Hi I am having problems while debugging my code. When I am running it this is an error that I receive in my browser: Parse error: syntax error, unexpected $end in c:\program files\apache group\Apache\htdocs\CT\getguestbook.php on line 40. Does anybody can help me out to with what exactly is wrong? <?php if (empty($_GET["Name"]) || empty($_GET["Email"])) die("<p> You must enter name and email. You need to go back to the Guestbook.</p>"); $DBConnect = @mysqli_connect("root", "", "") Or die("<p>Unable to connect to the database server.</p>" . "<p>Error code " . mysqli_connect_errno() . ":" . mysqli_connect_error()) . "</p>"; $DBName = "guestbook"; //creating database if (!@mysqli_select_db($DBConnect, $DBName)) { $SQLstring = "CREATE DATABASE $DBName"; $QueryResult = @mysqli_query($DBConncet, $SQLstring); mysqli_select_db($DBConnect, $DBName); $TableName = "visitors"; $SQLstring = "SELECT * FROM $TableName"; $QueryResult = mysqli_query($DBConnect, $SQLstring); if (!$QueryResult) { $SQLstring = "CREATE $TableName (countID SMALLINT NOT NULL AUTO INCREMENT PRIMARY KEY , guest_name VARCHAR(40), guest_email VARCHAR(40))"; $QueryResult = @mysqli_query($DBConnect, $SQLstring) or die("<p>Unable to create table .</p>" . "<p>Error Code " . mysqli_errno($DBConnect) . ":" . mysqli_error($DBConnect)) . "</p>"; } $Name = addslashes($_GET["Name"]); $Email = addslashes($_GET["Email"]); $SQLstring = "INSERT INTO $TableName VALUES(NULL, '$Name', '$Email')"; $QueryResult = @mysqli_query($DBConnect, $SQLstring) or die("<p>Unable to execute query.</p>" . "<p>Error Code " . mysqli_errno($DBConnect) . ":" . mysqli_error($DBConnect)) . "</p>"; echo "<h1>Thank you for signing our guestook.</h1>"; mysqli_close($DBConnect); ?> Quote Link to comment https://forums.phpfreaks.com/topic/175888-solved-syntax-error/ Share on other sites More sharing options...
Alex Posted September 29, 2009 Share Posted September 29, 2009 $end errors are generally caused by either missing or extra brackets ({, }). I popped your code into Notepad++ really fast and saw that the bracket on this line: if (!@mysqli_select_db($DBConnect, $DBName)) { isn't being closed anywhere. Quote Link to comment https://forums.phpfreaks.com/topic/175888-solved-syntax-error/#findComment-926752 Share on other sites More sharing options...
pinochio Posted September 29, 2009 Author Share Posted September 29, 2009 Thanks a lot. It is little bit hard for me to track everything especially syntax errors. Quote Link to comment https://forums.phpfreaks.com/topic/175888-solved-syntax-error/#findComment-926761 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.