Hello All,
Nice to meet you!
My website URL is: https://stephaneramael.world/test.php
In my php code I connect to mysql database using the mysqli class and query the Db using the method mysqli::query.
I see only the first of my echo statements confirming that the connection is successful:
Connect successful 0 3
I expect to see also the output of my other echo statements (data ‘first row&column’ taken from my database, followed by the count of rows):
testa 2
I do not use any software.
Here is a sample of my code:
/*connect to Db*/
$mysqli = new mysqli($db_server, $db_user, $db_pass, $db_name);
/* check connection */
if ($mysqli->connect_errno) {
echo "Connect failed ".$mysqli->connect_error;
exit();
} else {echo "Connect successful<br>";}
$sql = "SELECT * FROM test";
$exam_aArray = array();
if ($result = $mysqli->query($sql)) {
/* fetch associative array */
while ($row = $result->fetch_assoc()) {
array_push($exam_aArray, $row);
}
echo ("pass : " + $exam_aArray[0]['test_a'] + "<br>");
echo (count($exam_aArray));
}
/* close connection */
$mysqli->close();
the db contains the following:
id | test_a | test_b |test_c
1 | testa | testb | testc
2 | testa | testb | testc
3 | testa | testb | testc
It seems that the query method is not behaving as expected.
Please help!