php - mysqli_affected_rows() returns -1 but query works -


all mysql functions seem having problem. simple insert statement works, when check affected rows, returns -1.

this works, new row inserted database it, debugger shows mysqli_affected_rows -1, , therefore else block gets run:

$query = "insert users (email, password) values ('$email', '$password')";  mysqli_query($this->connection, $query) or die('query failed in register.');   if (mysqli_affected_rows($this->connection)>0)  {     //this doesnt run,  } else {    // run } 

why happen?

edit:

  • i'm using netbeans, xdebug, wamp.
  • when view connection after created, affected rows set -1.
  • after running successful query, connection still shows -1, before doing affected rows check.
  • no error messages or error numbers seen in connection object.

i had same problem. i've investigated issue netbeans , xdebug , seems bug in mysqli extension itself. according bug report has been made. in meantime can instead use more forgiving expression, e.g.

if (mysqli_sqlstate($dbc) == 00000) { //your code } 

to continue debugging remaining code.


Comments

Popular posts from this blog

php - render data via PDO::FETCH_FUNC vs loop -

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

The canvas has been tainted by cross-origin data in chrome only -