a stupid question about mysql database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
php12342005
Forum Commoner
Posts: 79
Joined: Mon Mar 21, 2005 3:35 am

a stupid question about mysql database

Post by php12342005 »

hi all,

assume my
web-site is http://www.my.com
ip address is 33.22.111.444

I created a database my_main and add an user my_user0 with password my_pswd0 to the database.

mysql_connect() function failed in php code bellow,
could u tell me why?

Thanks

php code
------------------------------------

$iphost="33.22.111.444";
$wbhost='http://www.my.com';
$dbuser='my_user0';
$psuser='my_pswd0';

//not working for both $wbhost and $iphost
$connection = mysql_connect($wbhost,$dbuser,$psuser);
if (!$connection)
{
echo(mysql_error()."\n");
die('Could not connect:');
}
else
{
echo("good!!!!!!\n");
}
Revan
Forum Commoner
Posts: 83
Joined: Fri Jul 02, 2004 12:37 am
Location: New Mexico, USA
Contact:

Post by Revan »

Code: Select all

$iphost="33.22.111.444";
$wbhost='http://www.my.com';
$dbuser='my_user0';
$psuser='my_pswd0';

//not working for both $wbhost and $iphost
$connection = mysql_connect($wbhost,$dbuser,$psuser);
if (!$connection)
{
echo(mysql_error()."\n");
die('Could not connect:');
}
else
{
echo("good!!!!!!\n");
}
Error..is?
php12342005
Forum Commoner
Posts: 79
Joined: Mon Mar 21, 2005 3:35 am

Post by php12342005 »

here is error code (by $iphost:

Warning: mysql_connect(): Access denied for user: 'my.com@venus.addaction.net' (Using password: YES) in /home/my/public_html/php/php00/test00.php on line 10
Access denied for user: 'my.com@venus.addaction.net' (Using password: YES)
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

your account 'my.com@venus.addaction.net' has no access to the database...


http://dev.mysql.com/doc/mysql/en/privilege-system.html
http://dev.mysql.com/doc/mysql/en/grant.html

Code: Select all

GRANT ALL ON mymain.* TO 'my.com'@'venus.addaction.net'
helloyaar
Forum Newbie
Posts: 3
Joined: Fri Jul 22, 2005 9:21 am

Try different user name

Post by helloyaar »

It seems that you have no access in your database with that user name. Supply a valid user name with valid password and see the magic :D
php12342005
Forum Commoner
Posts: 79
Joined: Mon Mar 21, 2005 3:35 am

Post by php12342005 »

Thanks to all,
I asked my host and fixed the problem.
correct syntax is
$connection=mysql_connect("",$dbuser,$psuser);
I must use "" to connect!
do you think it is strange?
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

Actually, that makes perfect sense. "", in this case, is equivalent to "localhost", the loopback address that you _should_ have been using.
Hernondo
Forum Newbie
Posts: 1
Joined: Sun Jul 24, 2005 11:19 pm

Post by Hernondo »

Sounds like you firewalled yourself!!
Post Reply