Hello - I am connecting to MySql and running a query. If I use a foreach loop, I can iterate over the results and have them print to screen. However, when I try the below everything is null!
How can I add the results of my MySql query to a php array?
<?php
$con=mysqli_connect("site", "user", "psasswr=ord", "db");
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql="SELECT * FROM test LIMIT 10";
$result = mysqli_query($con,$sql);
echo json_encode($result);
mysqli_free_result($result);
mysqli_close($con);
?>
but what this prints is:
{"current_field":null,"field_count":null,"lengths":null,"num_rows":null,"type":null}