I am reading an older book on php 5 that was copyrighted in 2011. I do not think its a good book at telling you where to place your curly brackets. Are my curly brackets correct? I get a blank screen after I fill in the form.
[php]
<?php error_reporting(E_ALL); ini_set('display_errors', 1); if (empty($_POST['first_name']) || empty($_POST['last_name'])) echo "You must enter your first and last name! Click your browser's back button to return to the Guest Book form.
"; else { $DBConnect = @mysql_connect("localhost", "user", "password"); if ($DBConnect === FALSE) echo "Unable to connect to the database server.
" . "Error code " . mysql_errno() . ": " . mysql_error() . "
"; else { $DBName = "guestbook"; if (!@mysql_select_db($DBName, $DBConnect)) { $SQLstring = "CREATE DATABASE $DBName"; $QueryResult = @mysql_query($SQLstring, $DBConnect); if ($QueryResult === FALSE) echo "Unable to execute the query.
" . "Error code " . mysql_errno($DBConnect) . ": " . mysql_error($DBConnect) . "
"; else echo "You are the first visitor!
"; } mysql_select_db($DBName, $DBConnect); } } $TableName = "visitors"; $SQLstring = "SHOW TABLES LIKE '$TableName'"; $QueryResult = @mysql_query($SQLstring, $DBConnect); if (mysql_num_rows($QueryResult) == 0) { $SQLstring = "CREATE TABLE $TableName (countID SMALLINT NOT NULL AUTO_INCREMENT PRIMARY KEY, last_name VARCHAR(40), first_name VARCHAR(40))"; $QueryResult = @mysql_query($SQLstring, $DBConnect); if ($QueryResult === FALSE) { echo "Unable to create the table.
" . "Error code " . mysql_errno($DBConnect) . ": " . mysql_error($DBConnect) . "
"; $LastName = stripslashes($_POST['last_name']); $FirstName = stripslashes($_POST['first_name']); $SQLstring = "INSERT INTO $TableName VALUES(NULL, '$LastName', '$FirstName')"; $QueryResult = @mysql_query($SQLstring, $DBConnect); if ($QueryResult === FALSE) echo "Unable to execute the query.
" . "Error code " . mysql_errno($DBConnect) . ": " . mysql_error($DBConnect) . "
"; else echo "Thank you for signing our guest book!
"; } mysql_close($DBConnect); } ?>[/php]