Trying to get my own php code to work on my website. Need Help.

Asked by:
HubFans / n/a Points
2014-09-12 8:24 am EST
Website Troubleshooting
I am writing a simple php / msql code for a leaderboard for a game I wrote. I am not able to get my php to connect to my database. Here is my comon.php code, am I not listing the URL right? :


$dbName = 'markgr7_score';
$secretKey = "wwi_1918~";

function dbConnect()
global $dbName;
global $secretKey;

$link = mysql_connect('', 'markgr7_gamer', 'wwi_1918~');

fail("CouldnĀ“t connect to database server");

fail("CouldnĀ“t find database $dbName");

return $link;

function safe($variable)
$variable = addslashes(trim($variable));
return $variable;

function fail($errorMsg)
print $errorMsg;


To ask this user for more information, please first login.

To submit an answer, please login.



16,266 Points
2014-09-12 8:55 am EST

In your mysql_connect parameters, change the server name from '' to 'localhost'. That should allow a connection. It is best to use 'localhost' whenever you have the database and php files on the same server.

Kindest Regards,
Scott M

To submit a comment on this answer, please first login.

Want to share this Question?

Related Articles

It looks like there are no related articles.
Would you like to ask a question about this page? If so, click the button below!

Help Center Search

Current Customers

Email: Ticket: Submit a Support Ticket
Call: 877-595-4HUB (4482)
757-416-6627 (Intl.)
Chat: Click To Chat Now

Ask the Community

Get help with your questions from our community of like-minded hosting users and Web Hosting Hub Staff.

Not a Customer?

Get web hosting from a company that is here to help.