Warning: file_exists(): open_basedir restriction in effect. File(/mounted-storage/home107c/sub002/sc63337-VMNH/www/devblog/wp-content/uploads/2023/02) is not within the allowed path(s): (/home/www/zoon.dk/:/tmp/domains/6aa/zoon.dk/:/usr/share/php_binaries/include/) in /home/www/zoon.dk/wp-includes/functions.php on line 2036

Warning: is_dir(): open_basedir restriction in effect. File(/mounted-storage/home107c/sub002/sc63337-VMNH/www/devblog/wp-content/uploads/2023) is not within the allowed path(s): (/home/www/zoon.dk/:/tmp/domains/6aa/zoon.dk/:/usr/share/php_binaries/include/) in /home/www/zoon.dk/wp-includes/functions.php on line 2047

Warning: is_dir(): open_basedir restriction in effect. File(/mounted-storage/home107c/sub002/sc63337-VMNH/www/devblog/wp-content/uploads) is not within the allowed path(s): (/home/www/zoon.dk/:/tmp/domains/6aa/zoon.dk/:/usr/share/php_binaries/include/) in /home/www/zoon.dk/wp-includes/functions.php on line 2047

Warning: is_dir(): open_basedir restriction in effect. File(/mounted-storage/home107c/sub002/sc63337-VMNH/www/devblog/wp-content) is not within the allowed path(s): (/home/www/zoon.dk/:/tmp/domains/6aa/zoon.dk/:/usr/share/php_binaries/include/) in /home/www/zoon.dk/wp-includes/functions.php on line 2047

Warning: is_dir(): open_basedir restriction in effect. File(/mounted-storage/home107c/sub002/sc63337-VMNH/www/devblog) is not within the allowed path(s): (/home/www/zoon.dk/:/tmp/domains/6aa/zoon.dk/:/usr/share/php_binaries/include/) in /home/www/zoon.dk/wp-includes/functions.php on line 2047

Warning: is_dir(): open_basedir restriction in effect. File(/mounted-storage/home107c/sub002/sc63337-VMNH/www) is not within the allowed path(s): (/home/www/zoon.dk/:/tmp/domains/6aa/zoon.dk/:/usr/share/php_binaries/include/) in /home/www/zoon.dk/wp-includes/functions.php on line 2047

Warning: is_dir(): open_basedir restriction in effect. File(/mounted-storage/home107c/sub002/sc63337-VMNH) is not within the allowed path(s): (/home/www/zoon.dk/:/tmp/domains/6aa/zoon.dk/:/usr/share/php_binaries/include/) in /home/www/zoon.dk/wp-includes/functions.php on line 2047

Warning: is_dir(): open_basedir restriction in effect. File(/mounted-storage/home107c/sub002) is not within the allowed path(s): (/home/www/zoon.dk/:/tmp/domains/6aa/zoon.dk/:/usr/share/php_binaries/include/) in /home/www/zoon.dk/wp-includes/functions.php on line 2047

Warning: is_dir(): open_basedir restriction in effect. File(/mounted-storage/home107c) is not within the allowed path(s): (/home/www/zoon.dk/:/tmp/domains/6aa/zoon.dk/:/usr/share/php_binaries/include/) in /home/www/zoon.dk/wp-includes/functions.php on line 2047

Warning: is_dir(): open_basedir restriction in effect. File(/mounted-storage) is not within the allowed path(s): (/home/www/zoon.dk/:/tmp/domains/6aa/zoon.dk/:/usr/share/php_binaries/include/) in /home/www/zoon.dk/wp-includes/functions.php on line 2047

Warning: is_dir(): open_basedir restriction in effect. File(/) is not within the allowed path(s): (/home/www/zoon.dk/:/tmp/domains/6aa/zoon.dk/:/usr/share/php_binaries/include/) in /home/www/zoon.dk/wp-includes/functions.php on line 2047

Warning: Cannot modify header information - headers already sent by (output started at /home/www/zoon.dk/wp-includes/functions.php:2036) in /home/www/zoon.dk/wp-content/plugins/wordpress-mobile-pack/inc/class-wmp-cookie.php on line 50
Windows 7 and PHP/MySQL | CODExperiments

Windows 7 and PHP/MySQL

Just spend a few hours getting Windows 7, Apache, PHP and MySQL up and running.

It should have been fairly easy, but there was a small problem.

While all the subparts worked independendly, PHP was unable to connect to the MySQL database.

MySQL was installed on localhost just to make it easy. However, this is were the trouble began. If you look in the hosts file in Windows 7 (c:\Windows\system32\drivers\etc\hosts) you will notice, that an important line has been commented out:

# 127.0.0.1     localhost

Now since this line is missing/commented out, PHP can’t find the IP for localhost. Remove the # sign, and save the file. PHP should be able to connect just fine now 🙂

As a note, you might run into trouble editing the file. Simply find Notepad in you start menu, right click and select “Run as administrator”. Notepad can now edit and save the changes made to the file.

I hope this blogpost saves someone else a bit of time.


One Response to “Windows 7 and PHP/MySQL”

  • zoonman Says:

    Please, see php.ini, [MySQL] section,
    you may setup mysql.default_host variable to 127.0.0.1
    And when you try to mysql_connect() define server to 127.0.0.1

Leave a Reply

You must be logged in to post a comment.