Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Open
argosback opened this issue Jan 29, 2014 · 4 comments

Comments

@argosback
Copy link

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

@Gummibeer
Copy link
Contributor

@argosback it would be nice if you can provide a pull-request with your solution. it's much easier to merge as copy'n'paste. ;)

@argosback
Copy link
Author

I send my pull-request :)

@Gummibeer
Copy link
Contributor

thx for #43 pull-request! :)
want to use this class in a big Project so i'm interestet in good solutions and a wide range of usability.

@behzad900
Copy link
Contributor

i fixed this just add utf8 charset in class.DPBO.php in $dns

$dsn      = 'mysql:dbname=' . DATABASE_NAME . ';host=' .DATABASE_HOST.';charset=utf8';




# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants