Hi, i am try to display and insert info on a person into my database but i keep getting this error whenever i enter the info
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'join (FName, LName) VALUES ('flsdjflsjfl','jsdlfjslfjvlj')' at line 1
<?php
include ("include.php");
if(!$_POST){
$display_block = "
<form method=\"post\" action=\"".$_SERVER["PHP_SELF"]."\">
<p><strong>First/Last Names:</strong><br/>
<input type=\"text\" name=\"FName\" size=\"30\" maxlength=\"75\">
<input type=\"text\" name=\"LName\" size=\"35\" maxlength=\"50\"></p>
<p><strong>Street:</strong><br/>
<input type=\"text\" name=\"Street\" size=\"50\"></p>
<p><strong>City/State/Zip:</strong><br/>
<input type=\"text\" name=\"City\" size=\"30\" maxlength=\"50\">
<input type=\"text\" name=\"State\" size=\"5\" maxlength=\"2\">
<input type=\"text\" name=\"Zip\" size=\"10\" maxlength=\"10\"></p>
<p><strong>Street Type:</strong><br/>
<input type=\"radio\" name=\"st_type\" value=\"home\" checked> home
<input type=\"radio\" name=\"st_type\" value=\"work\">work</p>
<p><strong>Telephone:</strong><br/>
<input type=\"text\" name=\"Phone\" size=\"30\" maxlength=\"25\">
<input type=\"radio\" name=\"tel_type\" value=\"home\" checked> home
<input type=\"radio\" name=\"tel_type\" value=\"work\" checked>work</p>
<p><strong>Email Address:</strong><br/>
<input type=\"text\" name=\"Email\" size=\"30\" maxlength=\"150\">
<input type=\"radio\" name=\"email_type\" value=\"home\" checked>home
<input type=\"radio\" name=\"email_type\" value=\"work\" checked>work</p>
<p><input type=\"submit\" name=\"submit\" value=\"Add Advocate\"></p>
</form>";
} else if($_POST){
if(($_POST["FName"] == "") || ($_POST["LName"] == "")){
header("location: addadvocate.php");
exit;
}
//connect to database
doDB();
$add_master_sql = "INSERT INTO join (FName, LName)
VALUES ('".$_POST["FName"]."','".$_POST["LName"]."')";
$add_master_res = mysqli_query($mysqli, $add_master_sql)
or die(mysqli_error($mysqli));
if(($_POST["Street"]) || ($_POST["City"]) || ($_POST["State"])
|| ($_POST["Zip"])){
$add_street_sql = "INSERT INTO join (Street, City, State, Zip)
VALUES ('".$_POST["Street"]."', '".$_POST["City"]."',
'".$_POST["State"]."', '".$_POST["Zip"]."')";
$add_street_res = mysqli_query($mysqli, $add_street_sql)
or die(mysqli_error($mysqli));
}
if($_POST["Phone"]){
$add_tel_sql = "INSERT INTO join (Phone) VALUES
('".$_POST["Phone"]."')";
$add_tel_res = mysqli_query($mysqli,$add_tel_sql)
or die(mysqli_error($mysqli));
}
if($_POST["Email"]){
$add_email_sql = "INSERT INTO join (Email) VALUES ('".$_POST["Email"]."')";
$add_email_res = mysqli_query($mysqli, $add_email_sql)
or die(mysqli_error($mysqli));
}
mysqli_close($mysqli);
$display_block = "<p>Your entry has been added. Thank you! Would you
like to <a href=\"addadvocate.php\">add another</a>?</p>" ;
}
?>
<html>
<head>
<title>Add an Entry</title>
</head>
<body>
<h1>Add an Entry</h1>
<?php echo $display_block; ?>
</body>
</html>