php - Query not inserting, but not giving error either -
php - Query not inserting, but not giving error either -
i got query , it's not inserting database it's not giving error either.
seek { $sth = $db->dbh->prepare("insert users (username,password,email,phone,first_name) values (:username,:password,:email,:phone,:firstname)"); $sth->execute(array(':username' => $username,':password' => $password, ':email' => $email,':phone' => $phone,':firstname'=>$firstname)); } catch(exception $e) { echo $e->getmessage(); exit(); }
i've tried inserting query command , works fine. there other insert queries on site , work fine too.. i'm not sure i'm doing wrong here
can seek this?
try { // prepare statement if (!($stmt = $mysqli->prepare("insert users (username,password,email,phone,first_name) values (?,?,?,?,?)"))) throw new exception("prepare failed: (" . $mysqli->errno . ") " . $mysqli->error); // bind parms if (!$stmt->bind_param("sssss", $username, $password, $email, $phone, $firstname)) throw new exception("binding parameters failed: (" . $stmt->errno . ") " . $stmt->error); // execute statement if (!$stmt->execute()) throw new exception("execute failed: (" . $stmt->errno . ") " . $stmt->error); } grab (exception $ex) { exit('error: '. $ex->getmessage()); }
p.s. tiij7
suggestion on comment question, 2 columns perm
, rank
- nullable
columns? if not, might have specify value @ time of row insertion.
more info here: http://php.net/manual/en/mysqli.quickstart.prepared-statements.php
php mysql
Comments
Post a Comment