0
這裏的功能:傳遞一個mysql連接到功能
function getCount($module, $db_link) {
if($module == "tweets") {
$query = "SELECT COUNT(*) FROM tweets WHERE `read`='n'";
$tweet_count = mysqli_query($db_link,$query);
echo $tweet_count;
}
}
這裏的鏈接(這是在代碼前面定義):
$mysqli = mysqli_connect("localhost", "twitterd", "password", "twitterd") or die('Cannot connect to the database');
函數調用:
<?php getCount("tweets", $mysqli); ?>
如何將$mysqli
鏈接傳遞給getCount函數?目前,我得到這個錯誤:
Catchable fatal error: Object of class mysqli_result could not be converted to string in lib.php on line 7
這是什麼問題? – 2012-07-21 04:52:24