php - Looping result from select statement throws error
Get the solution ↓↓↓ <?php
include 'config.php';
$query = sqlsrv_query($conn1, "SELECT * FROM dnmembership.[dbo].DNAuth a JOIN dnworld.[dbo] Characters b ON a.CharacterID = b.CharacterID where a.CertifyingStep = 2");
while($row = sqlsrv_fetch_array($query,SQLSRV_FETCH_ASSOC)){
echo $row['CharacterName']. '<br/>';
}
?>
This code gets met the folllowing error code: Warning: sqlsrv_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\usersonline.php on line 5
Anyone knows why?
Answer
Solution:
You are missing a period () between
{-code-2}
and{-code-3}
:
SELECT *
FROM dnmembership{-code-2}DNAuth a
JOIN dnworld{-code-2}{-code-3} b ON aCharacterID = bCharacterID
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: foreach() argument must be of type array|object, null given
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.