slmglc slmglc - 1 year ago 84
PHP Question

Nesting mysqli array and query funtions

$array = mysqli_fetch_array(mysqli_query($link,$result));

Is this a correct PHP/mysqli statement or do I have to run the query first and then the array fetching in two separate statements?


Answer Source

The code should do, what you want. Assuming the $result, despite the strange name, is really an SQL query string.

But this way, you cannot release resources associated with the query results.

So this is more correct:

$result = mysqli_query($link, $query);
$array = mysqli_fetch_array($result); 
// ...
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download