This works fine localhost but without a password and user as root Wanted to get my site running and I run into an issue I never ever had before but it has been a long time since i played with a website <?php $ip=$_SERVER['REMOTE_ADDR']; $title = 'MansonQuotes.com'; $host='misanthr'; $username='misanthr_MQuotes'; $password='password_removed'; $db_name='misanthr_mansonquotesDB'; $time=date("U"); $date=date('m/j/y g:i:s A'); mysql_connect($host,$username,$password)or die('cannot connect'); mysql_select_db(misanthr_mansonquotesDB)or die('cannot select DB'); ?> PHP: above is my exact config file except the password is removed. I am hosting off someone. When I try to connect, I get a long delay then this error Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on 'misanthr' (4) in /home/misanthr/public_html/config.php on line 10 cannot connect What am I doing wrong? EDIT: Im taking to my host and he thinks its some code on his end hes looking into. I am sure its not my end
Where is your database hosted? Is it on the same machine where you are running PHP code? If this is the case, then replace $host='misanthr'; with $host='localhost'; Another change you should do is use $db_name in mysql_select_db(). mysql_select_db($db_name)or die('cannot select DB');