Re: problem with mysql_real_escape_string()

From: Date: Thu, 28 Dec 2006 15:01:28 +0000
Subject: Re: problem with mysql_real_escape_string()
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-246260@lists.php.net to get a copy of this message
A little bit "lower" on php.net/manual I found explanation too. I'm sorry for bothering - wasn't check whole page before posting. The Warning was strange for me because never got it before :) Thanks for your help. -afan > afan@afan.net wrote: >> I moved my website from one php4/mysql4 based server to new hosting >> company and php5/mysq5 based server. >> Everything worked fine on old server, though now, on one page after I >> submit new record, I'll get this error: >> >> Warning: mysql_real_escape_string() [function.mysql-real-escape-string >> >> <https://www.mydomain.com/function.mysql-real-escape-string> >> ]: Access denied for user 'daemon'@'localhost' (using password: NO) in >> /srv/www/mydomain/add_record.php on line 30 >> >> Warning: mysql_real_escape_string() [function.mysql-real-escape-string >> >> <https://www.mydomain.com/function.mysql-real-escape-string> >> ]: A link to the server could not be established in >> /srv/www/mydomain.com/add_record.php on line 30 >> >> and this is a code: >> >> 26 if(isset($_POST['SubmitNewRecord'])) >> 27 { >> 28 foreach($_POST as $key => $value) >> 29 { >> 30 ${$key} = mysql_real_escape_string($value); >> 31 } >> 32 } >> >> Never got such a error message before. > > Check the archives - this was asked a few days ago. The > mysql_real_escape_string function requires a connection to the database > to be open. If one isn't open it will try to open one with the defaults. > All you need to do is make sure you connect to the mysql database before > using mysql_real_escape_string. > > -Stut >

« previous php.general (#246260) next »