Here is the problem code:
$categoryID = 1;
$productCode = 's%';
$db = new PDO('mysql:host=localhost;dbname=my_database',
'username', 'password');
$stmt = $db->prepare("SELECT * FROM products WHERE categoryID = :categoryID, AND productCode like :productCode");
$stmt->bindParam(':categoryID', $categoryID, PDO::PARAM_INT);
$stmt->bindParam(':productCode', $productCode, PDO::PARAM_STR);
$products = $db->execute();
When I run the above code, I keep getting an error saying "Fatal error: Call to undefined method PDO::execute()". Yet, when I google sample code for using prepared statements with PDO, they all use the execute() method.
Can someone tell me what's wrong, please? Thanks.