mysql_real_escape_string() error
Posted: 28 June 2008 01:33 PM   [ Ignore ]  
Grad Student
Avatar
Rank
Total Posts:  87
Joined  04-12-2008

I noticed in my logs I started getting the same error about 30 days ago (although diff. code line, probalby due to version difference).  They occur regardless of user activity on EE, about 5 - 10 every 1 - 3 minutes.  Log file is getting pretty big.

So if I read the above post correctly, resolution is to do a complete re-install or shutoff EE error logging in CP?

[01-Jun-2008 02:15:43] PHP Warning:  mysql_escape_string() [<a >function.mysql-real-escape-string</a>]: This function is deprecated; use mysql_real_escape_string() instead. in E:IIS_INTERNET_PUBwww_rootsupportdcrc_eedbdb.mysql.php on line 631

EE v1.6.3

Mod note- split from here as that was Tome related and this isn’t.

 Signature 

“You can’t fall off the floor” - Paul’s Law
“Brawndo, It’s what plants crave!” - Idiocracy

Profile
 
 
Posted: 29 June 2008 08:14 AM   [ Ignore ]   [ # 1 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  23523
Joined  05-20-2002

I’ll give the crew a ‘heads up’- I’m not sure it should be changed to use the new one, but I’m not sure it shouldn’t.  Was depreciated 4.3.0, new option only available as of 4.3.0.  But- I’d imagine putting some error suppression on it if left in makes sense.

For a short fix- could edit system/db/db.mysql around line 636- try using mysql_real_escape_string insteand of mysql_escape_string in:

if (function_exists('mysql_escape_string'))
        
{
        
return mysql_escape_string(stripslashes($str));
    
}


See if that does the trick.  And I’ll ask the crew as well.

Make sense?

 Signature 

AKA rob1

Help Request TipsPro Network

Profile
 
 
Posted: 30 June 2008 07:47 AM   [ Ignore ]   [ # 2 ]  
Grad Student
Avatar
Rank
Total Posts:  87
Joined  04-12-2008

If I change the check and invoking to mysql_real_escape_string I get the following for any site hit.

Site Error: Unable to Load Site Preferences; No Preferences Found

So there must be a syntax difference for the i/o, as if I just change the function name in the if test, mysql_escape_string() is still ran, so it recognizes the newer version of the function exists.

This function is identical to mysql_real_escape_string() except that mysql_real_escape_string() takes a connection handler and escapes the string according to the current character set. mysql_escape_string() does not take a connection argument and does not respect the current charset setting.

So I’m not sure I can modify the input properly with my limited understanding to be valid for the function.

Thanks for the reply!

 Signature 

“You can’t fall off the floor” - Paul’s Law
“Brawndo, It’s what plants crave!” - Idiocracy

Profile
 
 
Posted: 30 June 2008 07:55 AM   [ Ignore ]   [ # 3 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  23523
Joined  05-20-2002

Hm- yep, me too. 

Hang tight until I hear back from the crew.  If it’s just throwing messages, it’s not critical.  I’d rather wait to hear what they say than have you do too much experimenting.

Sound good?

 Signature 

AKA rob1

Help Request TipsPro Network

Profile
 
 
Posted: 30 June 2008 08:17 AM   [ Ignore ]   [ # 4 ]  
Grad Student
Avatar
Rank
Total Posts:  87
Joined  04-12-2008

Agreed, thanks for passing it on.

 Signature 

“You can’t fall off the floor” - Paul’s Law
“Brawndo, It’s what plants crave!” - Idiocracy

Profile
 
 
Posted: 01 July 2008 08:51 AM   [ Ignore ]   [ # 5 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  23523
Joined  05-20-2002

Are you seeing anything odd as a result- or is it just the error log?  And can you run down for me again both mysql version and php version?

And- do you have all errors showing?  I wonder if you test this in a template w/php turned on whether we can trigger the error:

<?php
error_reporting
(E_ALL );

if (
function_exists('mysql_real_escape_string'))
        
{
        
return mysql_real_escape_string(stripslashes($str));
    
}
?>

 Signature 

AKA rob1

Help Request TipsPro Network

Profile
 
 
Posted: 01 July 2008 10:00 AM   [ Ignore ]   [ # 6 ]  
Grad Student
Avatar
Rank
Total Posts:  87
Joined  04-12-2008

The above code does indeed invoke 3 duplicates of the error.

I do not see any results problems that I know of.  I’ve been focusing on getting data entered, generating the forms and learning the hierarchy, so I haven’t paid too close (nor do I have a lot of data) so that I can say definitely no, but I don’t think so.  Just filling up the logs.

PHP v5.2.6
MySQL Client api v5.0.51a (per PHP Info)
MySQL v5.0.51b-community-nt (per MySQL Administrator)

 Signature 

“You can’t fall off the floor” - Paul’s Law
“Brawndo, It’s what plants crave!” - Idiocracy

Profile
 
 
Posted: 06 July 2008 09:40 AM   [ Ignore ]   [ # 7 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  23523
Joined  05-20-2002

Just letting you know- crew is still looking into this one.

 Signature 

AKA rob1

Help Request TipsPro Network

Profile
 
 
Posted: 09 July 2008 11:03 AM   [ Ignore ]   [ # 8 ]  
Administrator
Avatar
RankRankRankRankRankRank
Total Posts:  6729
Joined  03-23-2006

Good morning leejb.  Apologies for the wait you sustained here.  I’ve identified and fixed the issue.  If you’d like to email me (derek.allard@ellislab.com) I’d be happy to provide you with a fixed file to test out.

 Signature 

DerekAllard.com - CodeIgniter, ExpressionEngine, and the World of Web Design
BambooInvoice - Open Source, CodeIgniter powered invoicing.

Profile
MSG
 
 
Posted: 19 September 2008 02:55 PM   [ Ignore ]   [ # 9 ]  
Summer Student
Avatar
Total Posts:  3
Joined  03-21-2008

Hey guys, I am running into the same issue.  I would like to replace the mysql_escape_string with mysql_real_escape_string.  Can you advise how to make this possible?  Currently if I replace it, I get the error mentioned above: “Site Error: Unable to Load Site Preferences; No Preferences Found”.

Thanks!

Profile
 
 
Posted: 21 September 2008 09:25 AM   [ Ignore ]   [ # 10 ]  
Administrator
Avatar
RankRankRankRankRankRank
Total Posts:  6729
Joined  03-23-2006

Hello fireengine,

The way the code in EE works in recent versions is to try mysql_real_escape_string() first, and only if that function doesn’t exist does it try mysql_escape_string(), so you should be fine.  Just be sure you’re running the latest version (and build) of EE.  You won’t need to modify any code to make this happen.

 Signature 

DerekAllard.com - CodeIgniter, ExpressionEngine, and the World of Web Design
BambooInvoice - Open Source, CodeIgniter powered invoicing.

Profile
MSG
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 64933 Total Logged-in Users: 53
Total Topics: 81900 Total Anonymous Users: 32
Total Replies: 440266 Total Guests: 256
Total Posts: 522166    
Members ( View Memberlist )
Newest Members:  Kathryn DaviesPetrovichusharurblaisdellLevagstudioigotthelemonmileswkakiharaAurels