douzhi1919 2015-09-23 09:11
浏览 17

mysql_num_rows()期望参数1在android [duplicate]处是资源错误

This question already has an answer here:

I am trying to send userid and otp which is entered in an edittext in an android app but from server side i get following response.

mysql_num_rows() expects parameter 1 to be resource, boolean given in /nfs/c07/h02/mnt/111018/domains/surun.co/html/demo/rest/api.php on line 168

line no 168 from php code

if(mysql_num_rows($results) > 0)

The php code in more details follows:

 public function selectQuery($table_name,$fields,$where="",$show = 0)

    {

       $i =0;

       if($where == "")

       $sql = "SELECT  ".$fields." FROM ".$table_name;

       else

       $sql = "SELECT  ".$fields." FROM ".$table_name." WHERE ".$where;

      //MySqli Select Query

      if($show == 1)

      return $sql;

      $results = mysql_query( $sql,$this->db );

      if(mysql_num_rows($results) > 0)

      {

        while($row = mysql_fetch_assoc($results))

        {

          $result[$i++]= $row;

        }

      }

      return $result;

    }
</div>
  • 写回答

1条回答 默认 最新

  • dongmieqiao3152 2015-09-23 09:45
    关注

    Read this link and apply these changes How could I change this mysql to mysqli? while also adding error checking in the form of

     $results = mysqli_query($this->db, $sql) or die (mysqli_error($connection));
    

    (or for MySQL just use $results = mysqli_query($sql,$this->db) or die (mysql_error()); )

    What you currently have is that your $this->db value is not connecting the database properly or you have a syntax error in your WHERE clause.

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥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 图论 物流运输优化