Free Web Hosting Forum
willettmatter willettmatter is offline
willettmatter is on a distinguished road
Posts: 61
Join Date: Jan 2012
Location: Idaho
Default mysql_real_escape_string - 02-21-2012, 05:35 PM

this is my test :

$creds=sprintf("uname='%s', pword='%s'", mysql_real_escape_string($uname), mysql_real_escape_string($pword));


here is the errors:
Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'a1345185'@'localhost' (using password: NO) in /home/a1345185/public_html/register/test.php on line 5

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/a1345185/public_html/register/test.php on line 5

What does it mean about the password?
Is there something else I'm missing?
Reply With Quote

you10's Avatar
you10 you10 is offline
Senior Member
you10 is on a distinguished road
Posts: 272
Join Date: Mar 2011
Location: England, UK
Default 02-21-2012, 06:31 PM

1. Your connecting to localhost not the mysql server, you need to use mysql* (replace the * with the mysql server you are on)
2. Databases have passwords, this will be the one you entered when you setup the database.

If you need help just ask

If I have helped you please give me karma
Reply With Quote
willettmatter willettmatter is offline
willettmatter is on a distinguished road
Posts: 61
Join Date: Jan 2012
Location: Idaho
Default 02-21-2012, 10:07 PM

This function has nothing to do with the data base. I only have the scripting that you see there.

Are you required to connect to the db to use this function?
Reply With Quote
Firebirds Firebirds is offline
Senior Member
Firebirds is on a distinguished road
Posts: 273
Join Date: Feb 2012
Default 02-21-2012, 10:28 PM

Your error means that you need to use a password, (the one you made while making the db) to login. Also, you cannot login at "localhost", you must use something that looks like mysql*

All your problems magically solved.
How to use custom domain. | Account under review? | Can I do this/whatever?
Have a happy magical day
Reply With Quote
grace1004 grace1004 is offline
Senior Member
grace1004 is on a distinguished road
Posts: 890
Join Date: Dec 2010
Default 02-21-2012, 11:23 PM

To use mysql_real_escape_string() function, you need to add database connection script as shown below.

PHP Code:
mysql_connect("""a336xxxx_test","******") or die(mysql_error());


$creds=sprintf("uname='%s', pword='%s'"mysql_real_escape_string($uname), mysql_real_escape_string($pword));

I tested a code similar to above in my localhost server, and it works fine.

Just for your information:

Even if "" is used as host in database connection script, the error message
will show something like 'a1345185'@'localhost' if there's something wrong with the script.
In other words, it's normal to have 'localhost' in the error message.

Last edited by grace1004; 02-21-2012 at 11:42 PM.
Reply With Quote


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: