I bought O'Reilley's book on MySQL and PHP, and tried an example in his book and its not working for squat...
Here is the code:
Code: Select all
<HTML>
<HEAD>
<TITLE>Bob</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#FF0000" VLINK="#800000" ALINK="#FF00FF" BACKGROUND="?">
<?php
// include 'db.inc';
// include 'error.inc';
if(empty($firstName) || empty($lastName))
{
?>
<form method="GET" action="DatabaseInputTest.php">
First_name:
<br>
<input type="text" name="firstName" size=80>
<br>Last_name:
<br>
<input type="text" name="lastName" size=80>
<br>
<input type="submit">
</form>
<?php
echo $lastName;
}
else
{
if (!($connection = @ mysql_connect( "localhost", "eletrium", "" )))
die("could not connect to database");
if (!mysql_select_db("Scheduler", $connection ))
showerror();
$insertQuery = "Insert into Customers values
(3, " .
""" . $firstName . "", " .
""" . $lastName . "", " . ")";
if((@ mysql_query ($insertQuery, $connection )) && @ mysql_affected_rows() == 1)
echo "<h3>Name Successfully Inserted</h3>";
else
showerror();
} // if else empty()
?>
</BODY>
</HTML>SOOOOOOOO, the issue is that I am having issues taking the form encoded data "?firstName=Bob&lastName=Robertson" and connecting it with the variables in PHP. $firstName and $lastName are ALWAYS blank atm.
Any ideas?
Thanks for the help in advance