I am having a problem getting a simple form to work. I keep getting an error in the select statement.
Error performing query: Unknown column '$zip' in 'where clause'
below is my code and it is driving me nuts. What am I doing wrong?
Read the Posting Guidelines before you post anything!!
Edited for eadability reasons.[php]
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<label>Please type in your billing Zip Code:<br />
<input type="text" name="zip" />
</label><br />
<input type="submit" value="Submit" />
</form>
<?
$zip = $_POST['zip'];
echo '<p>Zip Code:</p>';
// Request Zip Code Information
$result = @mysql_query('SELECT zip, city, state FROM zip WHERE zip=$zip');
if (!$result) {
exit('<p>Error performing query: ' .
mysql_error() . '</p>');
}
// Display the text of zip in a paragraph
while ($row = mysql_fetch_array($result)) {
echo '<p>' . $row['zip'], $row['city'], $row['state']. '</p>';
}
?>
[/php]
In the select statement, if I type in the value directly it works fine.
Thanks in advance
Frank Casser