Answer the question
In order to leave comments, you need to log in
MySQLi query result does not contain first row?
I am migrating from mysql to mysqli. It would seem banal, but I stumbled upon a problem. mysqli query returns one line less, or rather skips the first line, while mysql and phpmyadmin process the same query correctly.
Half a day I poke the engine, nothing helps. I decided to write a separate test script with only a request (so that the engine would definitely not affect the result in any way), the effect is the same, the first line is ignored.
$mysqli = new mysqli(DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
if ($mysqli->connect_error) {
echo 'Error: Could not make a database link (' . $mysqli->connect_errno . ') ' . $mysqli->connect_error;
}
$mysqli->query("SET NAMES 'utf8'");
$mysqli->query("SET CHARACTER SET utf8");
$mysqli->query("SET CHARACTER_SET_CONNECTION=utf8");
$mysqli->query("SET SQL_MODE = ''");
$result = $mysqli->query("SELECT * FROM setting WHERE qwe = '0'");
print_r($result); //mysqli_result Object ( [current_field] => 0 [field_count] => 6 [lengths] => [num_rows] => 535 [type] => 0 )
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question