I'm having problems with the following code:
# THIS FUNCTION CONNECTS TO MY DATABASE
function createSQLconnection(&$connection) {
$connection = mysqli_connect("typical", "yaddayadda", "crap");
// mysql_select_db("db", $connection);
if (!$connection) {
return "500";
} else {
return "200";
}
}
# THIS FUNCTION GETS ALL LOGS FROM MY DATABASE
function getLogs($conn, &$list, &$length) {
$sql = 'SELECT * FROM `db`.`logs`';
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
$i = 0;
while($row=mysqli_fetch_assoc($result)) {
$list[$i] = $row;
$i++;
}
$length = $i;
}
}
createSQLconnection($conn);
getLogs($conn, $logList, $logLength);
Everything seems fine up until this point:
for($row=0; $row<$logLength; $row++) {
echo $logList['photo_id'][$row];
echo $logList['name'][$row];
echo $logList['location'][$row];
}
No errors at all, no problems, just no text.
And even more confusing yet, when I dump the array:
print_r($logList);
Everything comes out just fine:
Array (
[0] => Array (
[uid] => 1
[name] => John Doe
[location] => Main Office
[photo_id] => State
[timestamp] => 1473365714
)
[1] => Array (
[uid] => 2
[name] => Joe Blow
[location] => New Office
[photo_id] => Passport
[timestamp] => 1473365738
)
)
I really don't understand. It should be so simple. Am I doing something wrong? What could I have possibly missed?