MySQL Forums
Forum List  »  MySQL Administrator

Unable to connect via browser but able to connect via command
Posted by: fei lee
Date: July 20, 2011 12:29AM

Dear Sir/Madam,

I created a php script to test db connection. Funny thing is while i execute this file via browser, i receive mysql error. If i execute the file via command, i can connect to database!

filename: connect.php

<?php
$conn = mysql_connect("ip_address","username","password");
if (!$conn)
die('Could not connect: ' . mysql_error());
else
print "connected!";
?>


#1 Execute connect.php at Reapfield Website:
http://localhost/connect.php
RESULT:

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'user'@'domain.com' (using password: YES) in /var/www/html/connect.php on line 2
Could not connect: Access denied for user 'user'@'domain.com' (using password: YES)

#2 Execute connect.php at my localhost via command:
php /var/www/html/connect.php
RESULT: Connected!

Is it because of firewall? or my.ini configuration problem?

Options: ReplyQuote


Subject
Written By
Posted
Unable to connect via browser but able to connect via command
July 20, 2011 12:29AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.