OO MySQLi help
Posted: Fri Jan 17, 2014 11:10 pm
I am trying to convert from some old MySQL functions to MySQLi
From what I can tell this should work but it is not... ?
From what I can tell this should work but it is not... ?
Code: Select all
// db connection include is working, but not shown.
// Generate a customer list
$sql='SELECT type, first_name, last_name, city, id FROM customers WHERE type = ?';
$type = 'R';
/* Prepare statement */
$stmt = $db->prepare($sql);
if($stmt === false) {
trigger_error('Wrong SQL: ' . $sql . ' Error: ' . $conn->error, E_USER_ERROR);
}
/* Bind parameters. TYpes: s = string, i = integer, d = double, b = blob */
$stmt->bind_param('s',$type);
$stmt->bind_result($type, $first_name, $last_name, $city, $id);
while ($stmt->fetch()) {
echo $last_name . ' ' . $first_name . ' - '. $city .'<br>';
}
$db->close();