简体   繁体   中英

Looping result from select statement throws error

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

You are missing a period ( . ) between [dbo] and Characters :

SELECT * 
FROM   dnmembership.[dbo].DNAuth a 
JOIN   dnworld.[dbo].Characters b ON a.CharacterID = b.CharacterID 
------------- Here -^
WHERE  a.CertifyingStep = 2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM