Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can you please explane this assignment? It gave me error? Sign Guest Book

Can you please explane this assignment? It gave me error?

Sign Guest Book 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("host", "user", "password"); if ($DBConnect === FALSE) echo "

Unable to connect to the database servr.

" . "

Error code " . mysql_errno() . ":" . mysql_errno(). "

";

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_INCEMENT PRIMARY KEY, last_name VARCHAR(40), first_name VARCHAR(40))"; $QueryReult = @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')"; $SQLstring = @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 signing our guest book!

"; } mysql_close($DBConnect) } } ?>

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

PostgreSQL 10 High Performance Expert Techniques For Query Optimization High Availability And Efficient Database Maintenance

Authors: Ibrar Ahmed ,Gregory Smith ,Enrico Pirozzi

3rd Edition

1788474481, 978-1788474481

More Books

Students also viewed these Databases questions