First, let me start by saying the website was working perfectly well on Dreamhost (except for the last week with horrible lags and downtime – but it was not what made me move away from them, read below).
I was hosting my website on Dreamhost. I had to move due to a problem with the owner of the revenue hosting (he’d not let me change a dns config on the panel nor would do it for me).
So I signed with HostGator, and now I’m stuck with this MySQL issue. Here’s what I’ve done so far:
First, I uploaded all the files via ftp to the HostGator server. Then, I exported the database from the old server and imported it onto the new one. Then I changed the name server on the domain registrar, and finally, after a while, hit F5 on the browser.
And then there was a huge ammount of error lines. So I searched the HostGator Support Portal and found out that I had to change from this (the code I was using before):
<?
date_default_timezone_set('America/Sao_paulo');
if ($_SERVER['HTTP_HOST']=='localhost') {
$conexao = mysql_connect("localhost");
$bd = mysql_select_db("tablename");
} else {
$conexao = mysql_connect("mysite.phpmyadmin.com","mylogin","mypassword");
$bd = mysql_select_db("mydatabasename");
}
mysql_query("SET time_zone='-3:00'");
?>
To something like this:
<?
define('DB_NAME', 'mydatabasename');
define('DB_USER', 'mylogin');
define('DB_PASSWORD', 'mypassword');
define('DB_HOST', 'localhost');
?>
The thing is I’m no PHP or MySQL expert. The programmer let me without support, so I’m on my own.
When I try to load my site, it gives the following errors:
Warning: mysql_query() [function.mysql-query]: Access denied for user 'mylogin'@'localhost' (using password: NO) in /home/mylogin/public_html/index.php on line 42
Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/mylogin/public_html/index.php on line 42
ERROR 40 >Access denied for user 'mylogin'@'localhost' (using password: NO)
On the file index.php, line 42 is this:
$sqlo = mysql_query("select *, max-buyers as left from offers inner join rel_city on rel_city.id_offer = offers.id where id_city=$city and startdate <= now() and enddate >= now() order by priority desc, left desc, enddate asc") or die("ERROR 40 >".mysql_error());
One important detail is that I need these two lines to work with the new hosting, but whenever I try to insert them, it gives new errors:
date_default_timezone_set('America/Sao_paulo');
mysql_query("SET time_zone='-3:00'");
Any ideas of how I can get this working?
Try this:
What I’ve done is simplify the original code to remove the IF / ELSE statement which looks like it might be there for development purposes.
If you’re getting other errors not posted, please include them.