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

Asked by:
HubFans / n/a Points
Time:
2014-09-12 3:24 pm EST
Category:
Website Troubleshooting
Hits:
129
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? :

<?php

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

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

$link = mysql_connect('secure39.webhostinghub.com', 'markgr7_gamer', 'wwi_1918~');

if(!$link)
{
fail("CouldnĀ“t connect to database server");
}

if(!@mysql_select_db($dbName))
{
fail("CouldnĀ“t find database $dbName");
}

return $link;
}

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

function fail($errorMsg)
{
print $errorMsg;
exit;
}

?>

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

To submit an answer, please login.

ANSWERS

0

ScottM
Staff
16,266 Points
2014-09-12 3:55 pm EST
Hello,

In your mysql_connect parameters, change the server name from 'secure39.webhostinghub.com' 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!
Need More Help?

Help Center Search

Current Customers

Email: support@WebHostingHub.com Ticket: Submit a Support Ticket
Call: 757-416-6627 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.
}