Showing posts with label Installation. Show all posts
Showing posts with label Installation. Show all posts

Sunday, April 29, 2007

Testing MySQL: Installing MySQL, configuring php.ini and removing deprecated tags.

Previously, I was testing MySQL and could not get a page to load at all. I was receiving the error message:
PHP Fatal error: Call to undefined function mysql_connect()

I added a couple extensions in php.ini and just now found a new error message appeared.
PHP Warning: PHP Startup: Unable to load dynamic library './php_mysql.dll'
- The specified module could not be found.\r\n in Unknown on line 0

It was not looking in the right directory, rather I never specified where to look. Now I have tried setting the extension directory with extension_dir = "c:\php\ext" in php.ini, I have received a new error message. (I'm getting somewhere!)
PHP Fatal error: Call to undefined function mysql_create_db() in
C:\\myserver\\test_mysql.php on line 33

I have a feeling I'll be doing a lot of php.ini configuring. After searching for the previous error in google I came across a list of emails in the archives of Neohapsis.com where someone mentioned that mysql_create_db() is deprecated. So much for using older tutorials. I searched for mysql_create-db() deprecated on Google and came across a comment on the manual that says mysql_query() should be used instead.

I went back into my test file and changed the two instances of mysql_create_db to mysql_query and finally something appears on the page. Unfortunately the variables are not appearing to be saved. Oh error looooog!,
PHP Warning: mysql_fetch_array(): supplied argument is not a valid MySQL
result resource in C:\\myserver\\test_mysql.php on line 66

Fetch doesn't have anything to fetch so it is reporting an error. I think I'll find someone elses file to test MySQL with (ignores the little voice saying "Make one yourself you lazy oaf")

Saturday, April 28, 2007

Installing MySQL

So I began by unzipping zip file into a folder of the same name. It really doesn't matter where it is unzippped. I now have setup.exe ready to run.

After it goes through a little song and dance preparing installation files and preparing to install it shows me a window, MySQL Server 5.0 - Setup Wizard

I click next> select custom (because I want to install in in c:/mysql instead of the default directory in Program Files)> click next> click change directory> enter c:/mysql under Folder name: > Click OK> click Next> click Install

After installation "Configure the MySQL Server Now" should be checked and I'll just click Finish and move on.

Friday, April 27, 2007

PHP, The Eternal Struggle

I've always wanted to set up a dynamic site but whenever I tried to create a local server for testing I would fall flat on my face. For the last few weeks after browsing through the thousands of pages of the manuals for Apache 2.2, PHP, and MySQL 5.0 I tried to installing PHP to run on Apache.

The first snag I ran into (and I should have seen it at the beginning) was my attempt to install PHP 5.1 with Apache 2.2.

It turns out that PHP 5.1 does not have "php5apache2_2.dll" which is needed to run Apache as a module for enhanced security. After downloading PHP 5.2 and adding the lines
LoadModule php5_module "c:/php/php5apache2_2.dll"
AddType application/x-httpd-php .php
PHPIniDir "C:/php"
I was finally able to start the Apache server without an error message. (c:/php was my choice of where I installed php. It might be different depending on where you unzipped your php file)

So I entered localhost and immediately became of forgetting a step. The Apache configuration file (httpd.conf) was still pointing at "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs" even though I had my root folder set up on the desktop. So I went into the file and found "DocumentRoot" where I promptly entered my desktop directory.

So I go to type in localhost and get the error message: 403 Forbidden You don't have permission to access / on this server. *frowns impatiently*

I go back into the httpd.conf file and scour through it line by line. Soon after DocumentRoot I encounter the problem:
# This should be changed to whatever you set DocumentRoot to.
#

About 26 lines after DocumentRoot it told me to change another line. So I pointed the directory to my desktop directory where all my files were located taking great care to use forward slashes (/) instead of backward slashes (\) and...

Htm files load perfectly but my test.php file comes up blank!