Free Web Hosting Forum
(#1)
Old
willettmatter willettmatter is offline
Member
willettmatter is on a distinguished road
 
Posts: 61
Join Date: Jan 2012
Location: Idaho
Default mysql_real_escape_string - 02-21-2012, 04:35 PM

this is my test :
$uname="bill";
$pword="fred";

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

print($creds);

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
(#2)
Old
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, 05:31 PM

1. Your connecting to localhost not the mysql server, you need to use mysql*.000webhost.com (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
(#3)
Old
willettmatter willettmatter is offline
Member
willettmatter is on a distinguished road
 
Posts: 61
Join Date: Jan 2012
Location: Idaho
Default 02-21-2012, 09: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
(#4)
Old
Firebirds Firebirds is offline
Senior Member
Firebirds is on a distinguished road
 
Posts: 274
Join Date: Feb 2012
Default 02-21-2012, 09: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*.000webhost.com


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

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

PHP Code:
<?php
$conn 
mysql_connect("mysql#.000webhost.com""a336xxxx_test","******") or die(mysql_error());
mysql_select_db("a336xxxx_test"$conn);

$uname="bill";
$pword="fred";

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

print(
$creds);
?>
I tested a code similar to above in my localhost server, and it works fine.

Just for your information:

Even if "mysql#.000webhost.com" 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 10:42 PM.
Reply With Quote
Reply

Tags
php

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 - 2014, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com