MySQL School Berkshire England Kingdom Reading Berkshire UK |
||||
0118 9352873 COMPUTER REPAIRS email: repairs@chephrenrepairs.com |
||||
| COMPUTER FIXER BLOG !CALL OUT CALCULATOR Ver1.1.4 !CONTACT US: !RSS Feed: ! Sunday, February 05th 2012 | ||||
|
Download Firefox to View Web Site
|
Internet Explorer 8 has a button Compatability View, use it if this page is poorly displayed. |
|||
email: repairs@chephrenrepairs.com | page end | news Cost from £20.00 per / hr
Firstly you should download the php zipped file it is called php-4.4.9-Win32.zip you will download this from php.net, you may use various mirrors from which to get the download. Try to pick a mirror reasonably close to wher you are!! Next we are not going to create a folder to put php into instead we are simply going to unzip straight in to the root of C: .I choose to use the program 7zip to unzip the folder straight into the directory C:/ you need to have the program 7zip, it is open source software and it can be downloaded easily from a few places on the net......
Ok... here we are talking about getting php version 4. whatever working and in this specific case we are talking about php 4.4.9. when we unzip the folder we downloaded we will unzip to c: that is the top of c the so called root. The unzipping will create a folder called php-4.4.9 and all the files php needs will be put in here by the unzipping process. [please note: if you were unzipping php 5. something you would most likely create a directory called php in the root of c and unzip into that, hence php 5 files would live in c:/php ]
We are talking about manually configuring php 4.4.9 on a windows XP computer for local use.
First thing to do look inside the php-4.4.9 folder in the root of you hard drive and find the file called php4ts.dll. What you should do is to copy this to C:\WINDOWS/system32. Notice I say copy not, move or delete or anything else!
To start find inside the folder called php-4.4.9 the file called php.ini-dist. copy this file into your WINDOWS folder. Once you have copied this file you should rename it to php.ini. Look you can use window copy and paste function to copy and paste a file from one location to another, an easy way to do this is to open up two windows explorer programs, All Programs ! Accessories ! Windows Explorer . Point one at the php-4.4.9 folder and one at C:/WINDOWS Folder. You can use right click on the file choose copy, then move to the other window, hover mouse inside that window representing C:/WINDOWS in some white space, right click mouse choose paste. Renaming a file is very straight forward, hover mouse over the file, right click mouse, choose rename and type in the new name.
Use Notepad to edit the file, open the file php.ini and read it slowly, find the line that says extension_dir = "./" You need to edit this to say extension_dir = "C:\php-4.4.9\extensions" Once you have edited it you must remember to save the file in the normal way. Notice that any changes in php.ini will probabably have no effect what so ever until you have rebooted your computer, so you should do that. Oftern when you are trying to get php to recognise mysql commands or functions you would add to php.ini
extension = php-mysql.dll
however, if you read the php.ini file you will see this;
;Windows Extensions
;Note that MySQL and ODBC support is now built in, so no dll is needed for it.
therefore you do not need to put in the line : extension = php-mysql.dll it is not required, it says so in php.ini. doesen't it!
You can edit the httpd.conf file using notepad once again, so where do you find this file, we tell you right here.....we are using Apache 2.0.63, look in explorer and look from the root of c
C:\Program Files\Apache Group\Apache2\conf\httpd.conf
The file that does the job of loading php into Apache is called php4apache2.dll now this file you will find here;
C:/php-4.4.9/sapi
You need to add to the bottom of httpd.conf file the following:
LoadModule php4_module "C:/php-4.4.9/sapi/php4apache2.dll"
This will effectively ensure that php is available to Apache..... now remember that in order to ensure that everything works correctly you will have to stop the apache server, and restart it, and in order to see the php module is active you may have to close the apache monitor and then open it up once again.
You can add these two lines to the bottom of the httpd.conf
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
Remember to save the file and stop and restart the apache web server.....
It is possible now that Apache will recognise many php functions in a php script and will also recognise prity much all the mysql functions. The way to tell is to create, using an editor, a web page, with a little php code in it, the code that we are going to use is straight forward php, and is just calling a mysql function and printing little stuff to the screen.
here is the script more or less:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body><?php
// this script tries to connect to the database server
// we use the function mysql-connect
$dbcon = mysql_connect('localhost','auser','thepassword');
if (!$dbcon) {
echo '<p> unable to connect to the '.
'database server.</p>';
exit();
} else
{
echo 'on line 21........';
}
?>
</body>
</html>
You write the script and save the web page and put it up to your web server. here are a few notes to help you:
1. You must use a user that exists on the mysql server clearly, plus you must use the correct password for that user.
2. The Script is clearly designed to connect to a local My SQL Server, so will only work for a MySQL Server running on the same computer as you local Web server. Your Web Server must be running.
3. Do not make any silly mistakes, common ones are as follows:
a. writing php lines with no ; at the end.
b. forgetting to save your web page or forgetting to put the page up to the local web server.
c. not matching your pairs of {} brackets.
d. the php must be inside the <body> </body> tags and you must ensure that the opening and cloasing php tags are exactly right ie <?php and ?>
We ran the web page and got an interesting error we got the following:
Warning: mysql_connect() [function.mysql-connect]: Client does not support authentication protocol requested by server; consider upgrading MySQL client in C:\Program Files\Apache Group\Apache2\htdocs\chephren\moretetingconn.php on line 11
unable to connect to the database server.