CodeIgniter Forums
1.6 mysql num_rows error - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forum-21.html)
+--- Thread: 1.6 mysql num_rows error (/thread-5779.html)

Pages: 1 2


1.6 mysql num_rows error - El Forum - 02-03-2008

[eluser]Tobz[/eluser]
Hi, I've just upgraded to CI 1.6

and I'm having a new mysql error in my error logs

ERROR - 2008-02-04 11:19:00 --> Severity: Warning --> mysql_num_rows(): supplied argument is not a valid MySQL result resource D:\web\Codeigniter\1.6.0\system\database\drivers\mysql\mysql_result.php 37

The weird thing is I'm not doing any sql in the controller/function that I'm calling (there is 1 sql call in the controller but different function).
So I don't know where to start debugging as its not in my code anywhere.

Any help would be appreciated.
Thanks


1.6 mysql num_rows error - El Forum - 02-03-2008

[eluser]Tobz[/eluser]
maybe I should note that it only appears in the error log and not on the page.


1.6 mysql num_rows error - El Forum - 02-03-2008

[eluser]tonanbarbarian[/eluser]
i would suggest looking further in the logs, see what is happening leading up to the warning
you may find it is the session handler for example
you may also want to add debug statements to all of your code so that you can track easier what is happening


1.6 mysql num_rows error - El Forum - 02-03-2008

[eluser]Tobz[/eluser]
I turned debuging vars on and this is a clean error log.
The error happens well before the controller is called.


DEBUG - 2008-02-04 12:00:17 --> Config Class Initialized
DEBUG - 2008-02-04 12:00:17 --> Hooks Class Initialized
DEBUG - 2008-02-04 12:00:17 --> URI Class Initialized
DEBUG - 2008-02-04 12:00:17 --> Router Class Initialized
DEBUG - 2008-02-04 12:00:17 --> Output Class Initialized
DEBUG - 2008-02-04 12:00:17 --> Input Class Initialized
DEBUG - 2008-02-04 12:00:17 --> Global POST and COOKIE data sanitized
DEBUG - 2008-02-04 12:00:17 --> Language Class Initialized
DEBUG - 2008-02-04 12:00:17 --> Loader Class Initialized
DEBUG - 2008-02-04 12:00:17 --> Config file loaded: config/demand/config.php
DEBUG - 2008-02-04 12:00:17 --> Helpers loaded: url, form, html, supply, array, date
DEBUG - 2008-02-04 12:00:17 --> Database Driver Class Initialized
DEBUG - 2008-02-04 12:00:17 --> Helpers loaded: form, html
DEBUG - 2008-02-04 12:00:17 --> Model Class Initialized
ERROR - 2008-02-04 12:00:17 --> Severity: Warning --> mysql_num_rows(): supplied argument is not a valid MySQL result resource D:\web\Codeigniter\1.6.0\system\database\drivers\mysql\mysql_result.php 37
DEBUG - 2008-02-04 12:00:17 --> Session Class Initialized
DEBUG - 2008-02-04 12:00:17 --> Session class already loaded. Second attempt ignored.
DEBUG - 2008-02-04 12:00:17 --> Controller Class Initialized
DEBUG - 2008-02-04 12:00:17 --> Final output sent to browser
DEBUG - 2008-02-04 12:00:17 --> Total execution time: 0.1645


1.6 mysql num_rows error - El Forum - 02-03-2008

[eluser]tonanbarbarian[/eluser]
are you autoloading any models? it appears you might be
look in those models and see if you have an code in the constructor that might be the issue


1.6 mysql num_rows error - El Forum - 02-03-2008

[eluser]Tobz[/eluser]
Nope, not autoloading any models.
the only extra coe in my model is:
Code:
$this->db->query("SET NAMES 'utf8'");
to fix php's buggy utf-8 mysql connection

this only happens with 1.6 if I downgrade back to 1.5.4(just changing index.php settings) it doesn't do it.


1.6 mysql num_rows error - El Forum - 02-03-2008

[eluser]Tobz[/eluser]
It seems to log this error on any page regardless of any database communication or not.


1.6 mysql num_rows error - El Forum - 02-03-2008

[eluser]tonanbarbarian[/eluser]
change the extra code in your model
Code:
$this->db->simple_query("SET NAMES 'utf8'");
the db->query tries to determine the number of rows returned
db->simple_query should not


1.6 mysql num_rows error - El Forum - 02-03-2008

[eluser]Tobz[/eluser]
Aha, that got it.
Would have taken me ages to figure it out. seems I'm one of the few people to use that function

maybe the Set Names query could be added to the mysql driver(just a thought) as it is one of the major things needed to support utf-8 chars properly? - at least it fixed all my problems. database problems anyway - lets not get started on string manipulation Smile

Thanks a lot for your help.


1.6 mysql num_rows error - El Forum - 02-03-2008

[eluser]Derek Allard[/eluser]
Take a trip through the database code in 1.6. Hit DB_driver in particular. I think you'll see that we've got you covered here Tobz.