samedi 25 juin 2016

Connecting MySQL database to website with PHP


As the title indicates I'm trying to link my MySQL database to my website using php. I'm using GoDaddy hosting for the MySQL database and I got this code directly from them and it's still not working for some reason, giving the error below. Here's my code : <?php $hostname = "trdlibrary.db.6253425.hostedresource.com"; $username = "*******"; $password = "*******"; $dbname = "trdlibrary"; $connect = mysqli_connect($hostname, $username, $password, $dbname, 3306) OR DIE ("Unable to connect to database! Please try again later or contact an administrator for help."); ?> Here's the error : Warning: mysqli_connect(): (HY000/2002): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in C:xampphtdocssearchenginedbconnect.php on line 6 Unable to connect to database! Please try again later or contact an administrator for help. Can anyone see the issue?.. or is this something I need to contact GoDaddy's support line about. -- EDIT -- I forgot to mention that I am running the web server off my local machine using XAMPP (so I can run the PHP scripts) but the MySQL server is off-site with GoDaddy, so 'localhost' won't work currently. -- EDIT #2 -- So I learned that sadly, remote access of MySQL databases to GoDaddy requires a more expensive and 'higher tier' hosting package from them. So I just answered my own question, thanks to those who replied.

Aucun commentaire:

Enregistrer un commentaire