Skip to content

query 'SET NAMES utf8' error: mysql_num_rows() expects parameter 1 to be resource #33

Open
@argosback

Description

@argosback

Hello, when I run the following query $db->ExecuteSQL('SET NAMES utf8'); I get the following error:

 # Line 121
 mysql_num_rows() expects parameter 1 to be resource, boolean given

I fixed with:

 @@ -118,8 +118,13 @@ class MySQL {
      function ExecuteSQL($query){
          $this->lastQuery     = $query;
          if($this->result     = mysql_query($query, $this->databaseLink)){
 -            $this->records   = @mysql_num_rows($this->result);
 -            $this->affected  = @mysql_affected_rows($this->databaseLink);
 +            if (gettype($this->result) === 'resource') {
 +                $this->records   = @mysql_num_rows($this->result);
 +                $this->affected  = @mysql_affected_rows($this->databaseLink);
 +            } else {
 +                $this->records  = 0;
 +                $this->affected = 0;
 +            }

If there is another way to run this query, please tell me

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions