Build your own Database Driven Website using PHP & MySQL - Part 1: Installation

This is a dedicated thread for discussing the SitePoint article ‘Build your own Database Driven Website using PHP & MySQL - Part 1: Installation

A great tutorial - well explained and thorough. Covers Windows as well as Linux/Mac OS X - something missing on other tutorials.

One word of warning though, there are a few cases where the instructions differ between this article and the PDF file I downloaded (first 4 chapters of the book). I think the PDF file had the correct info, as well as more details.

The article was written in 2001 and served as the starting point for the first edition of the book.

Absolute blunder … if anyone says that this tutorial is of no use …

We’re in the process of updating the article version of these sample chapters to coincide with the print version and the downloadable PDF.

Very good. Thank you very much for this article.

Real good article. got me started on PHP and MSQL in no time.

Can i get all the chapter remaining for free? ; )

Great. Good details to get you started

Thanks from starting from the beginning. I’ve used php before but your tutorial filled in a lot of gaps in my understanding of how it works. I look forward to chapter 2!

Note: PHP experts may tell you that you’ll achieve better performance with register_globals set to Off, but that setting exposes you to hackers attempting SQL injection attacks on your Website if you are not very careful to write scripts that protect themselves from such malicious behavior. Until you fully understand PHP and the types of security issues that scripts must combat, leave this setting On.

You’re talking about magic_quotes_gpc, right? (3rd edition [the article version], part 1, page 4, “Why should I bother?”)

Warning: Unexpected character in input: ‘\’ (ASCII=92) state=1 in C:\Program Files\Apache Group\Apache2\htdocs\ oday.php on line 2

Warning: Unexpected character in input: ‘\’ (ASCII=92) state=1 in C:\Program Files\Apache Group\Apache2\htdocs\ oday.php on line 2

Parse error: syntax error, unexpected T_STRING in C:\Program Files\Apache Group\Apache2\htdocs\ oday.php on line 2

when seting up the root password what about the ERROR 1044: Access denied for user @localhost to database root?

Yep, that’s right. It was an error in the adaptation from the book to the article. Fixed now.

CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers.

CGI Error

That error message indicates you have (incorrectly) installed the CGI version of PHP. If you follow the instructions in the article, you will install the module version of PHP, which cannot produce this error message.

Hi…I have the 2nd edition of your excellent book, and have tried to install everything, but PHP does not appear to be working. It’s on a Debian/Sarge system. Here is what I’ve done:

  • Installed MySQL 4.1 from tarball. That was successful, can log in at command prompt and do basic DB manipulation.
  • Installed Apache2 via apt-get. Also installed apache2-dev as instructed in book.
  • Compiled PHP 5 from source following book instructions. In order to make this work I had to install flex, xml2, xml2-dev, gcc and make, all of which I did via apt-get.

Then, still following instructions, I moved php.ini-dist and php.ini-recommended to /usr/local/php/lib and copied php.ini-dist to just plain php.ini
I added in values for doc_root and extension_dir as follows:
doc_root = /var/www
(I also tried /var/www/apache2-default, but still no luck)
extension_dir = “/usr/local/php”

And in the apache2-config file, I changed the DirectoryIndex line to include index.php index.php3 and index.phtml

And added the following two lines to the end:

AddType application/x-httpd-php .php .php3 .phtml
AddType application/x-httpd-php-source .phps

That’s all, then I made the sample web page from the book (today.php), and tried to load it from another machine on my network…but it wanted to download the PHP file, which I suppose means the server never tried to render it but just passed it through.

The URL for the PHP file is:
http://sneakypete.is-a-geek.com/apache2-default/today.php

Any suggestions?? I feel like I’m almost there…at least, I hope so!! Can’t wait to get cracking on the exercises in the book!

-Pete

Definitely sounds like you’re close. Any chance you neglected the ‘make install’ stage of PHP installation, and only did the ‘make’?

Check your Apache 2 config file… does it contain a LoadModule line for the PHP5 shared library (.so) file?

WOW that was quick, thanks!!

I do not have such a line in there, no.

This looks familiar - I think I found a similar suggestion on another forum this afternoon and tried it, but can’t remember exactly what I did. Whatever it was, I undid it!

Just tried this, which I found on a Gentoo forum. But it gave me an error. I put this line right before the AddType lines near the end of the apache2-config file:
LoadModule php5_module libexec/libphp5.so

and got this error when I tried to restart apache2:

Syntax error on line 398 of /etc/apache2/apache2.conf:
Cannot load /etc/apache2/libexec/libphp5.so into server: /etc/apache2/libexec/libphp5.so: cannot open shared object file: No such file or directory