slmglc slmglc - 6 months ago 40
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?



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); 
// ...