I'm would like to display all rows that contain $product:
<?
$product = "delta_44";
$conn = mysql_connect("localhost", "admin", "");
if (!$conn) {
echo "Unable to connect to DB: " . mysql_error();
exit;
}
if (!mysql_select_db("compare_price")) {
echo "Unable to select mydbname: " . mysql_error();
exit;
}
$sql = "SELECT * FROM `audio_interface` WHERE `product` = $product";
$result = mysql_query($sql);
if (!$result) {
echo "Could not successfully run query ($sql) from DB: " . mysql_error();
exit;
}
if (mysql_num_rows($result) == 0) {
echo "No rows found, nothing to print so am exiting";
exit;
}
while ($row = mysql_fetch_array($result)) {
extract($row)
?>
<table width='800'>
<tr>
<td width='122'><a href='<? echo "$product_url"; ?>'><? echo "$store"; ?></a></td>
<td width='666'><? echo "$price"; ?></td>
</tr>
</table>
<?
}
mysql_free_result($result);
?>
I'm getting this error:
Could not successfully run query (SELECT * FROM audio_interface WHERE product = delta_44) from DB: Unknown column 'delta_44' in 'where clause'
It seems to be looing for a colum named $product rather than a row containg $product.
Must be a problem with the sql call but I can not figure it out.