Page 1 of 1

a stupid question about mysql database

Posted: Sat Jul 23, 2005 3:57 am
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");
}

Posted: Sat Jul 23, 2005 4:00 am
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?

Posted: Sat Jul 23, 2005 4:17 am
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)

Posted: Sat Jul 23, 2005 7:15 am
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'

Try different user name

Posted: Sat Jul 23, 2005 9:06 am
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

Posted: Sat Jul 23, 2005 11:15 am
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?

Posted: Sat Jul 23, 2005 11:24 am
by Ambush Commander
Actually, that makes perfect sense. "", in this case, is equivalent to "localhost", the loopback address that you _should_ have been using.

Posted: Sun Jul 24, 2005 11:20 pm
by Hernondo
Sounds like you firewalled yourself!!