我知道 PHP 的 ext/mysql API 已经过时了,我不应该使用它,但这不是我的问题,我的问题是我有这段代码可以计算我表中的 id,它正在工作,但现在它没有,据我所知,没有任何理由。
有人可以告诉我我的代码哪里出错了谢谢。
我收到此错误:
Warning: mysql_query() expects parameter 2 to be resource, null given in /Applications/XAMPP/xamppfiles/htdocs/site.com/includes/functions.php on line 2023
Database query failed
我的桌子:
ptb_friend_requests
id | from_user_id | to_user_id | read_request | approved_request | delete_request
1 2 1 0 0 0
mysql代码:
function check_new_friends() {
global $connection;
global $_SESSION;
$query = "SELECT COUNT(id) FROM ptb_friend_requests WHERE to_user_id=".$_SESSION['user_id']." AND deleted_request='0' AND read_request='0' AND approved_request='0' AND from_user_id != '0'";
$check_new_friends_set = mysql_query($query, $connection);
confirm_query($check_new_friends_set);
return $check_new_friends_set;
}
html:
$check_profile_views_set = check_profile_views();
while ($newf = mysql_fetch_array($check_profile_views_set)) {
echo "<div class=\"friend-notify\">". $newf['COUNT(id)'] ."</div>";
//$check_new_duos_set = check_new_escort_duos(); while ($newd = mysql_fetch_array($check_new_duos_set)) { ?>
<? echo "". $newf['COUNT(id)'] .""; ?><? } ?>