query not working if WHERE variable not number
Posted: Tue May 18, 2010 10:33 am
The following query does not work if, let's say, $id = "2341f43". It works okay if $id only consists of numbers:
If it makes any difference, the 'item_num' column in the table is assigned varchar(20)
thank you for your assistance,
chop
Code: Select all
$q = "SELECT antiques_id FROM antiques WHERE item_num = $id LIMIT 1";
$r = @mysqli_query ($dbc, $q); // Run the query.
if ($r) {
$row = @mysqli_fetch_array ($r, MYSQLI_ASSOC);
echo $row['antiques_id'];
}
else {
echo ' querry did not work';
}
thank you for your assistance,
chop