Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database connection failures #9

Closed
mikegfink opened this issue Nov 24, 2014 · 1 comment
Closed

Database connection failures #9

mikegfink opened this issue Nov 24, 2014 · 1 comment

Comments

@mikegfink
Copy link
Collaborator

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);
}      

}

@mikegfink
Copy link
Collaborator Author

I think I've gotten that fixed. When I merged this time the database name was changed to something else and broke stuff..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants