I'm trying to use mysqli with Apache 2.0.63, Mysql 5.1.32, and Php 5.2.9-1 for Windows. Looking at phpinfo() I can see mysqli installed. I can also run a mysql query. However when I attempt to run a prepared statment I it fails at the if statement if($stmt->prepare($sql)) with the following message:
Could not run SQL statement: SELECT * FROM logins WHERE username = ? AND pwd = ?
Does anyone have any idea what I'm doing wrong?
$conn = new mysqli('127.0.0.1', 'user', 'password', 'the_db') or die ('Cannot open database');
$sql = 'SELECT * FROM logins WHERE username = ? AND pwd = ?';
$stmt = $conn->stmt_init();
if ($stmt->prepare($sql)){
//bind the query params
$stmt->bind_param('ss', $username, $password);
//execute the queryprepare
$stmt->execute();
}else{
die("Could not run SQL statement: $sql");
}