我想我将从代码开始:
$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)`必须是问题