when inserting new record table auto-incrementing id column, enough give id field value null or omit insert query, explained @ how insert new auto increment id
insert `database`.`table` (`id`, `user`, `result`) values (null, 'alice', 'green')");
or
insert `database`.`table` (`user`, `result`) values ('alice', 'green')");
my question - how do same thing when using prepared statements. have tried following, using null:
$stmt = $db->prepare("insert `db` (id, name, password, text) values (null, ?, ?, ?)"); $stmt->bind_param('sss', $name, $password, $text); $stmt->execute();
and fowllowing, omitting id field:
$stmt = $db->prepare("insert `test_db` (name, password, text) values (?, ?, ?)"); $stmt->bind_param('sss', $name, $password, $text); $stmt->execute();
when run nothing inserted , no error message in browser. think because trying insert duplicate value id field (stackoverflow.com/questions/12179770/…) - why should when seems equivalent non-prepared-statement way of inserting data, , give no message, i'm not sure.
any ideas welcome!
Comments
Post a Comment