I am having difficulty with the code I have written, as it does not connect by SQL database to my site.
I have recently made a website on dreamweaver, and it is now public and hosted by DreamHost.
I have also logged into the 'MySQL database management of Dreamhost' and created a database with multiple tables.
I have since created a PHP script to connect the database to my site and have uploaded it to the site. The following is an example of the script:
"
$db_host="andrewsmith.com";
$db_username="andrews";
$db_pass="*******";
$db_name="database345";
@mysql_connect("$db_host", "db_username", "$db_pass") or die ("Could not connect to
MySQL");
@mysql_select_db("$db_name") or die ("No database");
echo ("Successful connection");
?> "
However, my issue is the page always shows the message "Could not connect to MySQL". This is likely a coding problem, I just can't see where I have gone wrong. Does anyone have any suggestions?
Thanks for considering this question
James
A dreamhost database uses a subdomain to point to the actual mysql instance. There-for the fix will be adding mysql.domainname.com. You can find the correct database hostname in dreamhosts cpanel under databases.