Moving website and SQL database to a new host.

Associate
Joined
28 Jul 2008
Posts
468
Hi all,

We're moving our website which is written in PHP and has a SQL database. I've got the pages across and imported the database but something doesnt seem to work.

Should it be as simple as importing the database back into mySQL and amending the pages to suit the new database name and username/password?

Thanks in advance.
 
Are your DB connect details still right in the PHP? Are you using localhost still? Same Login/PW?
 
The database name has changed but I've amended it, the user name and password are the same.

There are no errors, it's just not returning any data. The connection to the database is fine as the login (which checks data on a table) works fine.

I'm stumped tbh :(

I've run the query directly from mySQL and it returns what I'm expecting but it seems like the server doesnt know what to do with the results.
 
Last edited:
Are you sure the username hasn't changed? If you're on a cPanel based host, your username and database name are preceded by your cPanel username.

E.g. it will be of the form cpaneluser_dbuser or cpaneluser_dbname
 
Hi both,

The PHP version is the same, and the SQL version on new host is slightly newer (5.0.86) vs old host at 5.0.81.

The user name did change, but I've accounted for that. It looks like the problem is just occuring when it's trying to put the data from the query into the page.

Update: it works... I'd put a _ instead of a - in the username... grrrrr

Thanks for the help guys.
 
Last edited:
Good stuff.

Now just write in a dbconnect fail catch so you know when the DB connection isnt working properly.
 
No worries. I've just stolen this from tizag.com (really simple tutorial site for learning)

<?php
mysql_connect("localhost", "admin", "1admin") or die(mysql_error());
echo "Connected to MySQL<br />";
?>
 
Do you mean something like

or die ("Cannot get users");

?

I'm having to learn all this from scratch!


If you use PDO you can just print the excpetion:

PHP:
try {
    /* All your normal connection stuff */
}
catch(PDOException $e) {
    echo $e->getMessage();
}
 
Back
Top Bottom