PHP Warning: mysql_num_rows():

Report bugs of current version 2.2.5 here!

Moderators: Moderator Team, Development Team

PHP Warning: mysql_num_rows():

Postby Oliver341 on Sat May 29, 2004 12:14 pm

Right. I've been doing some more digging into the problem which gave me the:

[Mon May 10 02:10:07 2004] [error] PHP Warning: Cannot modify header information - headers already sent by (output started at /home/celebrit/public_html/stats2/libraries/functions.lib.php:493) in /home/celebrit/public_html/stats2/pphlogger.php on line 226
[Mon May 10 02:10:07 2004] [error] PHP Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/celebrit/public_html/stats2/libraries/functions.lib.php on line 493

errors in my error logfile.

The problem occurs when someone is referred to my site from a search engine when " or ' is used in the search keyword. This has the effect of ruining the mysql query string, which means the mysql query is messed up, which means mysql_num_rows() does not get a valid database result to work with, which then produces the above error.

" is turned into \ by the keyword parsing code, and when this is at the END of a keyword query it has the effect of escaping the closing quote of the mysql database query string.
' is not removed by the keyword parsing code at all and obviously will close the quotes prematurely in a mysql query string.

I have cured this problem in my own copy of pphlogger by adding another stripslashes to remove the extra \ and by adding another ereg_replace to get rid of the ' character. I have not seen the error message since I did this.

I hope this information helps to fix this bug.

Oliver.
Oliver341
 
Posts: 19
Joined: Mon May 10, 2004 10:27 am

Postby sdjl on Sat May 29, 2004 3:23 pm

Would you mind posting the code you change in each of the files?
Explaining the problem is fantastic, but a lot of people would love to see some code to copy and paste over.

It would also save Philip from having to make edits for the big fix.

Thanks for looking into this, it's much appreciated.

David
User avatar
sdjl
Moderator
 
Posts: 1282
Joined: Mon Nov 17, 2003 1:13 am
Location: London, UK

Postby Oliver341 on Sat May 29, 2004 3:36 pm

sdjl wrote:Would you mind posting the code you change in each of the files?

No problem.

Look for
Code: Select all
$keywords=ereg_replace(""","",$keywords);
inside functions.lib.php.

Add these two lines after it:
Code: Select all
$keywords=ereg_replace("\'","",$keywords);
$keywords=stripslashes($keywords);

That should fix it.

Oliver.
Oliver341
 
Posts: 19
Joined: Mon May 10, 2004 10:27 am

Postby sdjl on Sat May 29, 2004 3:51 pm

Nice one :)

Thanks for taking the time to look into this. I shall pass on the thread to Philip :)

David
User avatar
sdjl
Moderator
 
Posts: 1282
Joined: Mon Nov 17, 2003 1:13 am
Location: London, UK

Postby Sergio on Sat Mar 12, 2005 6:25 pm

Thanks God for this forum, thanks God for this topic. It has been driving me crazy to find a solution to this error.

I have just installed it on my pphlogger, thanks.

Regards,
Sergio.
Sergio
 
Posts: 6
Joined: Sat Mar 12, 2005 6:03 pm


Return to PPhlogger bug reports

Who is online

Users browsing this forum: No registered users and 1 guest

cron