I"m attempting to create a simple selection box in PHP, but to no avail. It
keeps giving me an error:
You have an error in your SQL syntax near '; City='Eureka/'' at line 6
Here's a snip from my code:
<!-- newuser.php -->
<html>
<head>
<title> Add New User </title>
</head>
<body>
<?php
if (isset($_POST['submit'])):
// A new user has been entered
// using the form below.
$dbcnx = @mysql_connect('xxx.xxx.xxx','xxxxxxxx','lxxxxxxxxxx');
mysql_select_db('xxxxxxxxxx');
$sql = "INSERT INTO My_Table_Name SET
First_Name='$fname',
Last_Name='$lname',
Username='$username',
Password='$password',
Phone_Number='$phone';
City='$city'";
if (@mysql_query($sql)) {
echo('<p>New user added</p>');
} else {
echo('<p>Error adding new user: ' .
mysql_error() . '</p>');
}
?>
<p><a href="<?=$_SERVER['PHP_SELF']?>">Add another User</a></p>
<p><a href="add-user.php">Return to Users list</a></p>
<?php
else: // Allow the user to enter a new User
?>
<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
<p>Enter the new User:<br />
First Name: <input type="text" name="fname" size="20" maxlength="255" /><br
/>
Last Name: <input type="text" name="lname" size="20" maxlength="255" /><br
/>
UserName: <input type="text" name="username" size="20" maxlength="255" /><br
/>
Password: <input type="text" name="password" size="20" maxlength="255" /><br
/>
Phone: <input type="text" name="phone" size="20" maxlength="255" /><br />
City:<SELECT ID="City" NAME="city"/>
<OPTION VALUE=Eureka/>Eureka</OPTION/>
<OPTION VALUE=Rexford/>Rexford</OPTION/>
<OPTION VALUE=Trego/>Trego</OPTION/>
<OPTION VALUE=Fortine/>Fortine</OPTION/>
<OPTION VALUE=Other City/>Other City</OPTION/>
</SELECT/><br />
<input type="submit" name="submit" value="SUBMIT" /></p>
</form>
<?php endif; ?>
</body>
</html>
I've read and read - searched through other's posts, but haven't come up
with what I'm doing wrong. If anyone could give me a hand, I would greatly
appriciate it.
Scott
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php