php - Looping result from select statement throws error

279
    <?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?

61

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     



856
votes

Answer

--- Here -^ WHERE a.CertifyingStep = 2
532

Answer

--- Here -^ WHERE a.CertifyingStep = 2

People are also looking for solutions to the problem: php - SQL Select columns with comparison

Source

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.

Ask a Question

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.

Similar questions

Find the answer in similar questions on our website.