I am getting a Parse error on this code....any ideas?
<html>
<head>
<title>Input Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
if ( isset ( $first_name ) && isset ( $state )&& isset ($last_name)) {
//check input here
$dberror= "";
$ret = add_to_database ($first_name, $state, $last_name, $dberror );
if ( ! $ret )
print "Error $dberror<BR>";
else
print "Thanks you very much";
} else {
write_form();
}
function add_to_database ($first_name, $state, $last_name, &$dberror){
$username = "user77";
$password = "pass77";
$hostname = "localhost";
$db = "user77_homes";
$link = mysql_connect($hostname, $username, $password);
// or die("Unable to connect to MySQL");
if ( ! $link ) {
$dberror ="Couldn't connect to the server";
return false;
}
if ( ! mysql_select_db( $db, $link )) {
$db_error = mysql_error();
return false;
}
$query = "INSERT INTO foster_homes ( first_name, state, last_name)
values ( '$first_name', '$state', '$last_name' )";
if ( ! mysql_query( $query, $link ) ) {
$dberror = mysql_error();
return false;
}
return true;
}
function write_form() {
global $PHP_SELF;
print "<form method=\"POST\">\n";
print "<input type=\"text\" name=\"first_name\">";
print "The first name you would like<p>\n";
print "<input TYPE=\"text\" name-\"last_name\">";
print "Your last_name address<p>\n";
print "<select name=\"state\">";
print "\t<option value=\"CA\">CA\n";
print "\t<option value=\"MN\">MN\n";
print "</select>\n";
print "<input type=\"submit\" value=\"submit!\">\n</form>\n";
)
//mysql_close($link);
?>
</body>
</html>