Skip to main content
Help Center
The GoDaddy Community will undergo maintenance starting on Tuesday, August 3rd at 3pm PST / 6pm EST. Learn more
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Cant connect mysql database through php script remotely

I purchased a Linux Web Hosting because I need an online MySQL database. i have linux hosting.I need to access that database using .php scripts when i tried my code in localhost i got the result but if i put my website ip address to connect a data base i have created through cpanel with php admin . The php script will not give error but also will give no result. just blank. i will confess that i am novince in this area ...connecting a remote data base. please can someone be patient to tell me steps i should take to get my database running.  This is my code

//Sample Database Connection Syntax for PHP and MySQL.

//Connect To Database

$yourfield = "name";
$connection = mysql_connect($hostname, $username, $password);
mysql_select_db($dbname, $connection);

# Check If Record Exists

$query = "SELECT * FROM $usertable";

$result = mysql_query($query);

while($row = mysql_fetch_array($result))
$name = $row["$yourfield"];
echo "Name: ".$name."

when i run this on localhost without ip address it comes with result but if i have it access the mysql that i created in godaddy cpanel it comes out without resuly.