douyuanliao8815 2013-03-27 04:15
浏览 70

给出无法找到错误的mysql_fetch_array()布尔值[重复]

I now am getting this in my error log after fixing another problem. I've looked over everything on stackoverflow and all I come come up with is to get it to display an error, problem is I can't find where the error displays, so I can't troubleshoot it that way. Can anyone help give me some guidance? I'm not trying to do a duplicate, I'm really just trying to understand what is going on, sorry if this is misplaced (and if it is please let me know!).

This is the error:

[Wed Mar 27 01:36:41 2013] [error] PHP Warning:  mysql_fetch_array() expects parameter 1 to be resource, boolean given in /nas/wp/www/cluster-1434/XXXXXXX/wp-content/themes/mytheme/functions.php on line 574
[Wed Mar 27 01:36:14 2013] [error] PHP Warning:  mysql_fetch_array() expects parameter 1 to be resource, boolean given in /nas/wp/www/staging/XXXXXXX/wp-content/themes/mytheme/functions.php on line 572

This is line 572:

$ll = mysql_fetch_array($getLL);

This is line 574:

$cou = mysql_fetch_array($getCount);

Here is the code:

<?php
$con = conDB();
$x = 0;
//if ( false === ( $zip = get_transient( 'distinct_zips' ) ) ) {
$getZips = mysql_query("SELECT Distinct(meta_value) FROM wp_postmeta WHERE meta_key='_gmap_zip'",$con);
//$zip = mysql_fetch_array($getZips);
//  set_transient('distinct_zips', $zip, 60*5);
//}
while($zip = mysql_fetch_array($getZips)){
$getLL = mysql_query("SELECT * FROM zipcodes WHERE zip=".$zip['meta_value'],$con);
$ll = mysql_fetch_array($getLL);
$getCount = mysql_query("SELECT Count(*) FROM wp_postmeta WHERE meta_key='_gmap_zip' AND meta_value=".$zip['meta_value'],$con);
$cou = mysql_fetch_array($getCount);
$zipvalue = $zip['meta_value'];
$getNewest = mysql_query('SELECT * FROM wp_postmeta WHERE meta_key="_gmap_zip" AND meta_value="'.$zipvalue.'" LIMIT 5',$con);
if(strlen($ll['lat'])){
?>

Thanks in advance for all your help!

</div>
  • 写回答

3条回答 默认 最新

  • dtxf759200 2013-03-27 04:23
    关注

    The queries:

    $getLL = mysql_query("SELECT * FROM zipcodes WHERE zip=".$zip['meta_value'],$con);
    $getCount = mysql_query("SELECT Count(*) FROM wp_postmeta WHERE meta_key='_gmap_zip' AND meta_value=".$zip['meta_value'],$con);
    

    are failing returning false, leading to those two warnings.

    As a general rule of thumb you should always check for errors when dealing with queries. You can do that by running:

    if (!empty(mysql_error())) // error
    
    评论

报告相同问题?

悬赏问题

  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统