Here's the function:
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;
}
}
Here's the link (which is defined earlier in the code):
$mysqli = mysqli_connect("localhost", "twitterd", "password", "twitterd") or die('Cannot connect to the database');
The function call:
<?php getCount("tweets", $mysqli); ?>
How do I pass the $mysqli
link to the getCount function? Currently, I get this error:
Catchable fatal error: Object of class mysqli_result could not be converted to string in lib.php on line 7