I feel like the village idiot asking this, but I am new to PHP/MySQL and am stumped.
When I try to run my PHP page I get...
Parse error: syntax error, unexpected '>' in C:\wamp\www\NewAZlocal485site\addentry2.php on line 34
Here is my code:
<?php
if ((!$_POST) || (isset($_GET["master_id"]))) {
//haven't seen the form, so show it
$display_block = "
<form method=\"post\" action=\"".$_SERVER["PHP_SELF"]."\">";
if (isset($_GET["master_id"])) {
//connect to database
$mysqli = mysqli_connect("localhost", "pmbruner", "wolf2526", "pmbruner");
//get first, last names for display/tests validity
$get_names_sql = "SELECT concat_ws(' ', f_name, mi, l_name) AS display_name
FROM master_name WHERE id = '".$_GET["master_id"]."'";
$get_names_res = mysqli_query($mysqli, $get_names_sql)
or die(mysqli_error($mysqli));
if (mysqli_num_rows($get_names_res) == 1) {
while ($name_info = mysqli_fetch_array($get_names_res)) {
$display_name = stripslashes($name_info['display_name']);
}
}
}
if (isset($display_name)) {
$display_block .= "<p>Adding information for
<strong>$display_name</strong>:</p>";
} else {
$display_block .= "
<p><strong>First Name/MI/Last Name:</strong><br/>
<input type=\"text\" name=\"f_name\" size=\"30\" maxlength=\"20\">
<input type=\"text\" name=\"mi\" size=\"3\" maxlength=\"1\">
<input type=\"text\" name=\"l_name\" size=\"30\" maxlength=\"20\"></p>
}
$display_block .= "<p><strong>Address:</strong><br/>
<input type=\"text\" name=\"address\" size=\"30\"></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=\"zipcode\" size=\"10\" maxlength=\"10\"></p>
<p><strong>Address Type:</strong><br/>
<input type=\"radio\" name=\"add_type\" value=\"home\" checked> home
<input type=\"radio\" name=\"add_type\" value=\"work\"> work
<input type=\"radio\" name=\"add_type\" value=\"other\"> other</p>
<p><strong>Telephone Number:</strong><br/>
<input type=\"text\" name=\"tel_number\" size=\"30\" maxlength=\"25\">
<input type=\"radio\" name=\"tel_type\" value=\"home\" checked> home
<input type=\"radio\" name=\"tel_type\" value=\"work\"> work
<input type=\"radio\" name=\"tel_type\" value=\"fax\"> fax
<input type=\"radio\" name=\"tel_type\" value=\"other\"> other</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\"> work
<input type=\"radio\" name=\"email_type\" value=\"other\"> other</p>
<p><strong>Public Note:</strong><br/>
<textarea name=\"punote\" cols=\"35\" rows=\"3\" wrap=\"virtual\"></textarea></p>";
<p><strong>Personal Note:</strong><br/>
<textarea name=\"prnote\" cols=\"35\" rows=\"3\" wrap=\"virtual\"></textarea></p>";
if ($_GET) {
$display_block .= "<input type=\"hidden\" name=\"master_id\" value=\"".$_GET["master_id"]."\">";
}
$display_block .= "<p><input type=\"submit\" name=\"submit\" value=\"Add Entry\"></p>
</form>";
} else if ($_POST) {
//time to add to tables, so check for required fields
if (((($_POST["f_name"]=="") || ($_POST["mi"]=="") || ($_POST["l_name"]==""))) &&
(!isset($_POST["master_id"]))) {
header("Location: addentry.php");
exit;
}
//connect to database
$mysqli = mysqli_connect("localhost", "pmbruner", "wolf2526", "pmbruner");
if (!$_POST["master_id"]) {
//add to master_name table
$add_master_sql = "INSERT INTO master_name (date_added, date_modified, f_name, mi, l_name)
values (now(), now(),
'".$_POST["f_name"]."', '".$_POST["mi"]."', '".$_POST["l_name"]."')";
$add_master_res = mysqli_query($mysqli, $add_master_sql) or die(mysqli_error($mysqli));
//get master_id for use with other tables
$master_id = mysqli_insert_id($mysqli);
} else {
$master_id = $_POST["master_id"];
}
if (($_POST["address"]) || ($_POST["city"]) || ($_POST["state"]) || ($_POST["zipcode"])) {
//something relevant, so add to address table
$add_address_sql = "INSERT INTO address (master_id, date_added, date_modified,
address, city, state, zipcode, type) VALUES ('".$master_id."',
now(), now(), '".$_POST["address"]."', '".$_POST["city"]."',
'".$_POST["state"]."' , '".$_POST["zipcode"]."' , '".$_POST["add_type"]."')";
$add_address_res = mysqli_query($mysqli, $add_address_sql) or die(mysqli_error($mysqli));
}
if ($_POST["tel_number"]) {
//something relevant, so add to telephone table
$add_tel_sql = "INSERT INTO telephone (master_id, date_added, date_modified,
tel_number, type) VALUES ('".$master_id."', now(), now(),
'".$_POST["tel_number"]."', '".$_POST["tel_type"]."')";
$add_tel_res = mysqli_query($mysqli, $add_tel_sql) or die(mysqli_error($mysqli));
}
if ($_POST["email"]) {
//something relevant, so add to email table
$add_email_sql = "INSERT INTO email (master_id, date_added, date_modified,
email, type) VALUES ('".$master_id."', now(), now(),
'".$_POST["email"]."', '".$_POST["email_type"]."')";
$add_email_res = mysqli_query($mysqli, $add_email_sql) or die(mysqli_error($mysqli));
}
if ($_POST["punote"]) {
//something relevant, so add to notes table
$add_notes_sql = "UPDATE public_notes set note = '".$_POST["punote"]."' WHERE
master_id = '".$master_id."'";
$add_notes_res = mysqli_query($mysqli, $add_notes_sql) or die(mysqli_error($mysqli));
}
if ($_POST["prnote"]) {
//something relevant, so add to notes table
$add_notes_sql = "UPDATE personal_notes set note = '".$_POST["prnote"]."' WHERE
master_id = '".$master_id."'";
$add_notes_res = mysqli_query($mysqli, $add_notes_sql) or die(mysqli_error($mysqli));
}
mysqli_close($mysqli);
$display_block = "<p>Your entry has been added. Would you like to <a href=\"addentry.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>
Where am I going wrong?