When I execute sql queries in my php application using MySQLi, the errors are always empty or zero, so disconnecting me from registering or printing is pretty unpleasant ... I have not experienced any problems inserting, updating or deleting data using below when the request should not cause an error.
I use PHP 5.3.9 in the community version of Zend Server 5.6.0 and mysqli mysqlnd 5.0.8-dev - 20102224 - $ Edition: 318113 $
This is the code that fulfills my requests:
... $this->last= $this->mysqli->query($sql); if (!$this->last) { print_r($this->mysqli); var_dump($this->mysqli->error); var_dump($this->mysqli->errno); var_dump($this->mysqli); $msg = 'Query failed [ ' . $this->mysqli->error . ' ]'; $this->mysqli->rollback(); throw new Exception($msg, ...); } ...
For testing purposes, I entered a city with the name "bob" into the database and tried to insert another city with the same name, and this is what was printed:
mysqli Object ( ... [errno] => 1062 [error] => Duplicate entry 'bob' for key 'unq_city' ... ) string(0) "" int(0) object(mysqli)#6 (18) { ... ["errno"]=> int(0) ["error"]=> string(0) "" ... }
Here, using var_dump or accessing errno or the error of my mysqli object, as I said, is null. HOWEVER print_r shows the expected error! What am I doing wrong here? I have never used mysqli before and go with oci8, so I hope this is just some kind of stupid mistake.
Edit:
I tested my application on an older server, PHP 5.3.8, ZSCE 5.5.0 and mysqlnd 5.0.8-dev - 20102224 - $ Revision: 310735 $ with identical configuration from what I can say. All dumps and fingerprints displayed all mysqli data without any empty field!
source share