Jump to content

PHP database connection problem in webserver


tanvirtonu

Recommended Posts

Hello I m new to php. I have uploaded a simple php script in my web root - http://www.mydomain.com which will connect to my DB.

But strangely I CANT connect to my DB if I put the hostname as my real hostname - mydomain.com . But if I use - localhost , it works. How come its working as- localhost when I am not on localhost.

<?php
echo "HELLO WORLD";
$connect = mysql_connect("localhost","username","mypassword") or die ("couldn't connect db"); // it works
//$connect = mysql_connect("www.mydomain.com","username","mypassword") or die ("couldn't connect db"); // it DOESN'T work
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.