PHPee.com PHP development forum
PHP Warning: mysql_num_rows():

 
Post new topic   This topic is locked: you cannot edit posts or make replies.    phpee.com Forum Index -> PPhlogger bug reports
View previous topic :: View next topic  
Author Message
Oliver341



Joined: 10 May 2004
Posts: 19
Location: Sussex, UK

PostPosted: Sat May 29, 2004 11:14 am    Post subject: PHP Warning: mysql_num_rows(): Reply with quote
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.
Back to top
View user's profile Send private message Visit poster's website
sdjl
Moderator


Joined: 17 Nov 2003
Posts: 967
Location: London, UK

PostPosted: Sat May 29, 2004 2:23 pm    Post subject: Reply with quote
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
_________________
-----
Free Logger Accounts | PPHlogger Manual | PM Me
Back to top
View user's profile Send private message Visit poster's website
Oliver341



Joined: 10 May 2004
Posts: 19
Location: Sussex, UK

PostPosted: Sat May 29, 2004 2:36 pm    Post subject: Reply with quote
sdjl wrote:
Would you mind posting the code you change in each of the files?

No problem.

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

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

That should fix it.

Oliver.
Back to top
View user's profile Send private message Visit poster's website
sdjl
Moderator


Joined: 17 Nov 2003
Posts: 967
Location: London, UK

PostPosted: Sat May 29, 2004 2:51 pm    Post subject: Reply with quote
Nice one Smile

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

David
_________________
-----
Free Logger Accounts | PPHlogger Manual | PM Me
Back to top
View user's profile Send private message Visit poster's website
Sergio



Joined: 12 Mar 2005
Posts: 1

PostPosted: Sat Mar 12, 2005 5:25 pm    Post subject: Reply with quote
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.
Back to top
View user's profile Send private message
Post new topic   This topic is locked: you cannot edit posts or make replies.    phpee.com Forum Index -> PPhlogger bug reports All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB
Theme design based on Team 101 Designs, modified by Philip Iezzi