开发者

MySQL while loop won't stop

开发者 https://www.devze.com 2023-03-03 13:28 出处:网络
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百科

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

精彩评论

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