I've been going around with this for a while now and can't get it to work... The prepare statements in my version of the code keep returning false...
eg
Fatal error: Call to a member function bind_param() on a non-object in /Users/mikefink/Documents/CS304/amsstore/views/customer/customer_reg.php on line 96
Besides that, the examples I've seen use as a guard on the prepare statements to prevent errors on the bind_param calls.
if ($stmt = $mysqli->prepare("SELECT District FROM City WHERE Name=?")) {
}
function insertIntoDB($name, $addr, $tel, $id, $pass){
//Since $connection was declared in another page
// within the site, we call global on it
global $connection;
$stmt = $connection->prepare("INSERT INTO customer (cid, c_password, c_name, address, phone) VALUES (?,?,?,?,?)");
var_dump($stmt);
// Bind the title and pub_id parameters, 'sss' indicates 3 strings
$stmt->bind_param("sssss", $id, $pass, $name, $addr, $tel);
// Execute the insert statement
$stmt->execute();
// Print any errors if they occured
if($stmt->error) {
printf("<b>Error: %s.</b>\n", $stmt->error);
} else {
echo "<b>Successfully added ".$id."</b>";
unset($_POST);
}
I've been going around with this for a while now and can't get it to work... The prepare statements in my version of the code keep returning false... eg Fatal error: Call to a member function bind_param() on a non-object in /Users/mikefink/Documents/CS304/amsstore/views/customer/customer_reg.php on line 96
Besides that, the examples I've seen use as a guard on the prepare statements to prevent errors on the bind_param calls. if ($stmt = $mysqli->prepare("SELECT District FROM City WHERE Name=?")) { }
function insertIntoDB($name, $addr, $tel, $id, $pass){ //Since $connection was declared in another page // within the site, we call global on it global $connection; $stmt = $connection->prepare("INSERT INTO customer (cid, c_password, c_name, address, phone) VALUES (?,?,?,?,?)");
}