Error: mysql

This question already has an answer here:

  • mysql_fetch_array()/mysql_fetch_assoc()/mysql_fetch_row()/mysql_num_rows etc… expects parameter 1 to be resource 31 answers

  • try this code:

    foreach($data as $fl){  
        $result = @mysql_query(sprintf("SELECT * FROM useri WHERE fb_id='%s'", $fl["uid"]));
        if(is_resource($result) &&  mysql_num_rows($result) >=  1) {
           while ($row = mysql_fetch_array($result)) {
              $list[] = $row;
           }
        }
    }
    

    try problem is (as defined by @Farnabaz earlier) that not every iteam in $data has uid therefore my code is just a fail-safe method


    mysql_query returns a boolean false if it encounters an error. Use mysql_error() to get a readable error message from MySQL.


    not all items in $data has uid ( $data['5'] dose not have uid ) and it cause to execute query like this:

    SELECT * FROM useri WHERE fb_id = 
    

    and this is error

    链接地址: http://www.djcxy.com/p/69226.html

    上一篇: PHP

    下一篇: 错误:mysql