Search code examples
phpmysqlxampplocalhostmysql-connect

mysql connect - Moving my website to a local host


I've created a website using a CMS. I've been making updates to the live site and, finally after months of "tsk tsk" from my dev friends have decided to create a local version on my computer to test updates on before making live.

I copied all of the files and the DB to a folder. Then, using XAMPP transferred the files to local host

> http://localhost/mywebsite/

I then created a new database in phpmyadmin called "mywebsite" and imported the downloaded database successfully.

Now, when I navigate to

> http://localhost/mywebsite/

I receive the following message:

An error was detected which prevented the loading of this page. If this problem persists, please contact the website administrator. core.error_file_line mysql_connect() [function.mysql-connect]: Unknown MySQL server host 'mywebsitecom.fatcowmysql.com' (1)

Presumably I must link the database with the CMS on my computer. I imagine that this must sound very simple to most people on Stack Overflow but my PHP and DB skills are limited.

Is it immediately apparent to anybody what actions I need to take next to complete local set up?


Solution

  • In your mysql_connect call you are giving it mywebsitecom.fatcowmysql.com as a host, locate your code file where you connect to MySQL and change that value to localhost

    like

    $link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
    

    Better not to use mysql_* functions anyway :)