开发者

MySQL while loop won't stop

I've recently created a PHP/MySQL while loop which fetches an array based on my parameters. From what I know about doing this, it should end when there are no more rows to grab. Mine just开发者_C百科 keeps going until I stop the page loading.

while($row = mysql_fetch_array(mysql_query("SELECT username,password,title,message FROM notifications WHERE dateset = '$date'"))){
    $test = new Boxcar($row['username'],$row['password']); 
    $test->send($row['title'],$row['message']);
}


try like this most likely the inline query is being rerun everytime you step through the while loop

$result = mysql_query("SELECT username,password,title,message FROM notifications WHERE dateset = '$date'");

while($row = mysql_fetch_array($result)) {
    $test = new Boxcar($row['username'],$row['password']); 
    $test->send($row['title'],$row['message']);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜