I am trying to create a editing page, but I keep getting an error:
Error updating member details: 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 'WHERE business_id=''' at line 7
The version on the server for MYSQL is 5.0.45
I have been through and through the coding and the manual and I cannot see the syntax error.
Any help would be very gratefully received.
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>edit member page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
</style>
</head>
<body>
<?php require 'secure.inc.php' ?>
<?php
// connect to the database server
$dbcnx = @mysql_connect('localhost', 'xxx', 'xxxxxx');
if (!$dbcnx) {
exit('<p>Unable to connect to the database server at this time.</p>');
}
// select the members database
if (!@mysql_select_db('qba_org_uk_membership')) {
exit('<p>Unable to locate the members database at this time.</p>');
}
if (isset($_POST['business_name'])):
// The business details have been updated.
$business_name = $_POST['business_name'];
$contact_name = $_POST['contact_name'];
$business_email = $_POST['business_email'];
$business_telephone = $_POST['business_telephone'];
$business_mebership_type = $_POST['business_mebership_type'];
$sql = "UPDATE members_list SET
business_name='$business_name',
contact_name='$contact_name',
business_email='$business_email',
business_telephone='$business_telephone',
business_mebership_type='$business_mebership_type',
WHERE business_id='$business_id'";
if (@mysql_query($sql)) {
echo '<p>Member details updated.</p>';
} else {
echo '<p>Error updating member details: ' .
mysql_error() . '</p>';
}
?>
<p><a href="database_home_page.php">Home Page</a></p>
<?php
else: //allow the user to edit the member
$business_id = $GET['business_id'];
$result = @mysql_query(
"SELECT business_name, contact_name, business_email, business_telephone, business_mebership_type FROM members_list WHERE business_id='$business_id'");
if (!result) {
exit('<p>Error fetching business deatils: ' .
mysql_error() . '</p>');
}
$result = mysql_fetch_array($result);
$business_name = $result['business_name'];
$contact_name = $result['contact_name'];
$business_email = $result['business_email'];
$business_telephone = $result['business_telephone'];
$business_mebership_type = $result['business_mebership_type'];
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<p>Edit the member:</p>
<label>Business Name: <input type="text" name="business_name"
value="<?php echo $business_name; ?>" /></label><br />
<label>Contact Name: <input type="text" name="contact_name"
value="<?php echo $contact_name; ?>" /></label><br />
<label>Business Email: <input type="text" name="business_email"
value="<?php echo $business_email; ?>" /></label><br />
<label>Business Telephone: <input type="text" name="business_telephone"
value="<?php echo $business_telephone; ?>" /></label><br />
<label>Business Membership Type: <input type="text" name="business__mebership_type"
value="<?php echo $business__mebership_type; ?>" /></label><br />
<input type="hidden" name="busness_id" value="<?php echo $busness_id; ?>" />
<input type="submit" value="SUBMIT" /></p>
</form>
<?php endif; ?>
</body>
</html>