PHP mysql_fetch_array在while表达式中不会运行

时间:2014-08-05 16:22:17

标签: php mysql

我想我将从代码开始:

$result = mysqli_query($con,"SELECT * FROM Streams");
$pers = -1; // if zero stream is already in DB.

print_r($result);
// Check if stream is already persistent in DB
while( $row = mysql_fetch_array($result) ) {

    // If stream is already persistent and online is 0 this means
    // the streamer just got online so a tweet is posted
    print("Online:");
    print_r($row['online']);
    if( strcmp($row['link'],$url) && ($row['online'] == 0) ) {
        postTweet($display_name, $status, $url);
        $updateQuery = "UPDATE Streams SET online = 1, name = '".$display_name."', title = '".$status."' WHERE link = '".$url."'";
        mysqli_query($con, $updateQuery);
        $pers = 0;
    }
    else if ( strcmp($row['link'],$url) && ($row['online'] != 0 )) {
        // Stream was already online the last time the script ran
        // No tweet is posted
        $pers = 0;
    }

}

我得到了这个输出:

mysqli_result Object ( [current_field] => 0 [field_count] => 4 [lengths] => [num_rows] => 1 [type] => 0 )

数据库只有一个表格。 $result变量对我来说很好看,但不知怎的,while循环赢了t run, otherwise at least "Online" should have been printed out, so somehow $ row = mysql_fetch_array($ result)`必须是问题

0 个答案:

没有答案