php - mysqli bind_param does not set $stmt->error or $stmt->errno -


according php manual can retrieve errors in prepared statement method interrogating $stmt->error , $stmt->errno bind_param method never seems set these on error, can else confirm this? or tell me missing please?

for example:

echo "start\n"; $db = new mysqli('localhost','test','xxxxxx','test'); $val = 1; $st = $db->prepare('insert tbltest set field1=?'); if($st == false) { printf("prepare: %s %d\n",$db->error,$st->errno); } $rs = $st->bind_param('is', $val); if($rs == false) { printf("bind_param: %s %d\n",$st->error,$st->errno); } $rs = $st->execute(); if($rs == false) { printf("execute: %s %d\n",$st->error,$st->errno); } $rs = $st->close(); if($rs == false) { printf("close: %s %d\n",$st->error,$st->errno); } echo "finish\n"; 

running above command line displays:

start php warning: mysqli_stmt::bind_param(): number of elements in type definition string doesn't match number of bind variables in test.php on line 14 bind_param: 0 execute: no data supplied parameters in prepared statement 2031 finish 

so php seeing warning, bind_param returning false, error & errno not set. execute failing , has correctly set error & errno

is bug?

mysqli::error , mysqli::errno containers error codes , messages returned rdbms php, not errors encountered in php code when setting statement. incorrect call bind_param() (with insufficient parameters) apparently not communicate rdbms, , won't receive error rdbms.

according to docs, bind_param() returns boolean false on failure. need verify called successfully.

$rs = $st->bind_param('is', $val); if ($rs) { $st->execute(); } 

Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -