我在错误日志中不断收到此错误,但我不知道为什么。我到处寻找并用谷歌搜索,但我迷路了,我需要帮助:
[Wed Mar 27 02:14:56 2013] [error] PHP Warning: mysql_query() expects parameter 2 to
be resource, null given in /nas/wp/www/cluster-1434/XXXXXXXX/wp-content/themes/mytheme
/groups/single/home.php on line 23
[Wed Mar 27 02:14:56 2013] [error] PHP Warning: mysql_fetch_array() expects
parameter
1 to be resource, null given in /nas/wp/www/cluster-1434/XXXXXXXX/wp-content/themes
/mytheme/groups/single/home.php on line 24
这是它引用的代码:
$getlatlong = mysql_query("SELECT * FROM zipcity WHERE zip='".$url[2]."'",$con);
$ll = mysql_fetch_array($getlatlong);
如果您需要,这是完整的代码:
<?php
global $bp;
global $current_user;
$group_name = $bp->groups->current_group->name;
$group_id = $bp->groups->current_group->id;
$groupll = groups_get_groupmeta( $group_id, $meta_key = 'latlong');
$groupnamecount = strlen($group_name);
$groupcity = groups_get_groupmeta( $group_id, $meta_key = 'city');
$groupstate = groups_get_groupmeta( $group_id, $meta_key = 'state');
$mapaddress = $group_name.'+'.$groupcity.'+'.$groupstate;
if ($groupnamecount == '5')
{
$grouptype = "zip";
}
if ($grouptype == "zip") {
$url = explode('/',$_SERVER['REQUEST_URI']);
$zip = $url[2];
$getlatlong = mysql_query("SELECT * FROM zipcode WHERE zip='".$url[2]."'",$con);
$ll = mysql_fetch_array($getlatlong);
} else {
$groupcity = groups_get_groupmeta( $group_id, $meta_key = 'city');
$groupstate = groups_get_groupmeta( $group_id, $meta_key = 'state');
$mapaddress = $group_name.'+'.$groupcity.'+'.$groupstate;
}
更新
问题是 $con 在代码的下方被声明了。一旦我解决了这个问题,它就完美地工作了。感谢所有回答!