0

Hi all,

I am a student trying to access a database that is on a different server than where my web pages are stored. My webpages running PHP scripts are here (128.118.142.34 through 128.118.142.46) and my database is here (146.186.83.60)
Here is the code that I implemented:

$con = mysql_connect(146.186.83.60, username, password) or die ('Error connecting to mysql');
mysql_select_db(databasename, $con);

The IP is where my database is located, but I get an error message:

Warning: mysql_pconnect() [function.mysql-pconnect]: Can't connect to MySQL server on '146.186.83.60' (4) in /pass/home/14/t/tmv105/www/Connections/diehl.php on line 9

Fatal error: Can't connect to MySQL server on '146.186.83.60' (4) in /pass/home/14/t/tmv105/www/Connections/diehl.php on line 9

Might I be being denied access due to a firewall, and if so, is there PHP code to work around this?

3
Contributors
3
Replies
9
Views
8 Years
Discussion Span
Last Post by spthorn
0

PHP code is correct but it seems that you are facing the problem due to firewall settings. Add your web server IP addresses (where you PHP script is stored) in firewall allowed list and also make sure that port 3306 is not blocked in the server firewall.

Kailash

0

I thank you for this information, but I do not have access to the server firewall connections where the database is stored. Is there possibly a work around without access?

(I think I may be unclear also as to why I would add my webserver addresses to the server where my PHP script is stored? My PHP scripts are on the webserver and I need to access my database on another server with my PHP scripts from my webserver. Does this make sense or I am not describing this clearly? I appreciate any help that you can provide!)

Thanks!

Tara :)

0

No workaround is available via PHP. That wouldn't make sense; allowing PHP to somehow override firewall settings would be somewhat dangerous. :-)

If you can't access the db server, the firewall is blocking it, so add the db server IP to the firewall allowed list.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.