PHP MySql Setup

Here is my idiots guid to working with PHP 5, MySql, and Apache on a windows server.

This assumes you have downloaded all of the above mentioned apps and have them installed. If not you can get them here: (PHP , MySQL)

Configure PHP 5 to start talking to MySql.

UPDATE with php 5.2.6 and Apache 2.2 I had to use these instructions –

  1. open your php.ini file because you have to add a few entries. (example C:\php\php.ini)
  2. Once open search for Windows Extensions
  3. Then add this line “extension=php_mysql.dll ” after it and do not put the ignore “;” in front of it like the others that might already be in the config
  4. While in the php.ini file search for “extension_dir” and make sure it has a correct path. (example:extension_dir = “c:\php\ext”)
  5. Double check that mysql is running in your services.
  6. Restart Apache and check the phpinfo() page to make sure you now have a mysql section before moving on to the next steps.
  7. Restart apache
  8. Now setup a test php script page with the following

< ?php // we connect to and port 3306 which is the default $link = mysql_connect('localhost:3306', 'root', 'password'); if (!$link) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully'; mysql_close($link); [/sourcecode] Hopefully you get the following response on the page when you view it. "Connected successfully" Troubleshooting Tips:

  • You can use telnet to see if the service is running. start > run > telnet localhost 3306 should give you some sort of response.
  • Check (C:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf) for the following entries : PHPIniDir “C:/PHP/” and LoadModule php5_module “C:/PHP/php5apache2_2.dll”

Leave a Reply

Your email address will not be published. Required fields are marked *