Actually I am not getting any errors now...but it is not writing to the db. I started out with only three fields and that worked fine...but after I added the rest it stopped working.
I added to the other code I posted as well as the the write_form() section here is all the code it is kinda long...
if ( isset ( $first_name ) && isset ( $id_num ) && isset ( $state )
&& isset ( $email ) && isset ( $address ) && isset ( $city )
&& isset ( $zip ) && isset ( $phone ) && isset ( $other_animals )
&& isset ( $type_wanted ) && isset ( $kids ) && isset ( $yard )
&& isset ( $sleep ) && isset ( $state ) && isset ( $comments )
&& 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 = "olivia77_draspen";
$password = "wolly";
$hostname = "localhost";
$db = "olivia77_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 fosters_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;
//global $_POST;
print "<form method=\"POST\">\n";
print "First Name:\n";
print "<input type=\"text\" name=\"first_name\">";
print "<p>Last Name:\n";
print "<input TYPE=\"text\" name=\"last_name\">";
print "<p>Address:\n";
print "<input TYPE=\"text\" name=\"address\">";
print "<p>City:\n";
print "<input TYPE=\"text\" name=\"city\">";
print "<p>State:\n";
print "<select name=\"state\">";
print "\t<option value=\"CA\">CA\n";
print "\t<option value=\"MN\">MN\n";
print "</select>\n";
print "<p>Zip:\n";
print "<input TYPE=\"text\" name=\"zip\">";
print "<p>Email:\n";
print "<input TYPE=\"text\" name=\"email\">";
print "<p>Phone:\n";
print "<input TYPE=\"text\" name=\"phone\">";
print "<p>What type of animal will you foster?\n";
print "<select name=\"type_wanted\">";
print "\t<option value=\"small dog\">Small Dog\n";
print "\t<option value=\"Med. Dog\">Med. Dog\n";
print "\t<option value=\"Large Dog\">Large Dog\n";
print "\t<option value=\"Cat\">Cats\n";
print "\t<option value=\"Multiple Cats\">Multiple Cats\n";
print "\t<option value=\"Misc. Pets\">Misc. Pets\n";
print "</select>\n";
print "<p>Do you have other Animals?:\n";
print "<select name=\"other_animals\">";
print "\t<option value=\"No\">No\n";
print "\t<option value=\"Yes\">Yes\n";
print "</select>\n";
print "<p>Do you have a kids?\n";
print "<select name=\"kids\">";
print "\t<option value=\"No\">No\n";
print "\t<option value=\"Yes\">Yes\n";
print "</select>\n";
print "<p>Do you have a yard?\n";
print "<select name=\"yard\">";
print "\t<option value=\"No\">No\n";
print "\t<option value=\"Yes\">Yes\n";
print "</select>\n";
print "<p>Where will the pet sleep?\n";
print "<input TYPE=\"text\" name=\"sleep\">";
print "<p>Comments:\n";
print "<input TYPE=\"text\" name=\"comments\">";
print "<p>\n";
print "<input type=\"submit\" value=\"submit!\">\n</form>\n";
// print "<input type=\"submit\" value=\"submit!\">\n";
// print "$query\n</form>\n";
}