home

articles

broadband

browsers

fraud001

javascript001

javascript002

javascript003

links

mysql01

mysql02

mysql03

mysql04

php001

php002

php003

problem001

spyware

virus01

virus02

web_programming

Sponsor001

 

MY SQL

Part 1 - GETTING STARTED - Page 2

CONFIGURE APACHE

Locate the file C:\Apache\conf\httpd.conf and open it with Notepad or WordPad. Find the line AddModule mod_setenvif.c

Add the following 3 lines:

    LoadModule php5_module c:/php/php5apache.dll

    AddModule mod_php5.c

    AddType application/x-httpd-php .php .phtml

Save the file.

CONFIGURING PHP.INI

Open C:\Windows\php.ini with Notepad

Locate [mail function]

My outgoing mail is smtp.ntlworld.com and my email is jim@mp3science.com so my php.ini file reads:

[mail function]

; For Win32 only.

SMTP = smtp.ntlworld.com

Smtp_port = 25

 

; For Win32 only.

sendmail_from = jim@mp3science.com

 

Locate doc_root and change the line to read:

 

doc_root = "C:\Apache\htdocs"

 

Locate extension_dir and change it to read:

 

extension_dir = "C:\php\ext"

 

Locate the list of extensions and change the appropriate one to read:

 

extension= "php_mysql.dll"

 

Notice that the semicolon has been removed from the beginning of these lines!

RUNNING MySql

This is very important to get right. After installing MySql, restart the computer and wait for the following program to run:

C:\mysql\bin\WinMySqlAdmin.exe

This program will be the 2nd window to open, the 1st window is mysqld-opt.exe. Eventually a 3rd window will appear, asking you for a user name and password. The data that you enter is stored in a file:

C:\WINDOWS\my.ini

If everything has gone correctly, you should see a 'Traffic Light' icon in the right hand start menu. A green light means MySql has started, red means it hasn't. The next time you run the computer, MySql should automatically start, and you should get the green light.

MY.INI

After downloading a virus, I had to reinstall MySql. However, I couldn't get the program to work again! Eventually, I decided to delete the my.ini file. This did the trick, because MySql uses my.ini during start up. So I can only assume that it was configured incorrectly. I entered the user name and password again, and it seems to be working correctly.

TESTING APACHE

Start Apache by clicking on C:\Apache\Apache.exe

A small window will open, Click Twice for a picture.

Open Internet Explorer, and type in the URL field, http://localhost

If all has gone correctly, you will see in the browser title, "Test page for Apache Installation". Click Twice for a picture.

HTDOCS

This folder already exists, and is located at:

C:\Apache\htdocs, where the server looks for your PHP files. This was set when you configured php.ini

You could change that but please make sure you know what you're doing. Otherwise, just put all the PHP files in the htdocs folder.

For example, the file below is: C:\Apache\htdocs\phpinfo.php but to run it, you type: http://localhost/phpinfo.php You don't have to tell it to look in 'htdocs' because php.ini tells the server where to look.

TESTING PHP

This requires you to create a file with the following text:

<?php phpinfo(); ?>

Save it as phpinfo.php so that the full path reads:

C:\Apache\htdocs\phpinfo.php

Now type in the URL field http://localhost/phpinfo.php

And you should see, "phpinfo()" in the browser title, and lots of information about PHP. Click Twice for a picture.

TESTING MySql

Type the following code into notepad, and save as C:\Apache\htdocs\mysqltest.php

<html>

<head>

<title>MySQL Connection</title>

</head>

<body>

<h2>

 

<?php

    $connection = mysql_connect( "localhost", "root", "" )

    or die( "Unable to connect to MySQL" );

    echo( "Connected to MySQL ok" );

?>

</h2>

</body>

</html>

Now type http://localhost/mysqltest.php and you should see, "Connected to MySQL ok".

Continued