I got a problem retrieving data from a database. So I have a page that has a search box. A user types in an item number and gets redirected to a single item page with transferring that number using form . Then a script picks that number and shows only a result where that number equals a result number. PROBLEM: everything works well if that number consists of numbers only. If we add letters it goes to "PHP Fatal error: Call to a member function execute() on a non-object". In a database I set this be TEXT, not NUMBER.
Here is the code on a single item page:
So first it gets that number from top URL (part.php?partnumber=WB20K10023+):
$item_number = $_GET['item_number'];
$allItems = fetchAllItems($item_number);
Then it runs this function:
function fetchAllItems($item_number) {
global $mysqli,$db_table_prefix;
$stmt = $mysqli->prepare("SELECT
*
FROM ".$db_table_prefix."items
WHERE
item_number = $item_number
LIMIT 1
");
$stmt->execute(); // <- This line shows in an error_log
$stmt->bind_result($id);
while ($stmt->fetch()){
$row[] = array('id' => $id);
}
$stmt->close();
return ($row);
}