Monthly Archives: June 2011

Forays into PHP and MySQL

I expressed a desire in an entry from last November that I wanted to learn, among other things, PHP (and its integration with MySQL, a relational database management system). I haven’t had the time to do any of that with my ridiculous schedule but I finally got a chance to start my foray into PHP this week. Despite the popularity of PHP, just getting the darn thing up and running was in itself a challenge for me, and it took two days and at least four separate installations before I finally got it right.

Using a six-year old PHP/MySQL guidebook, I started off by downloading and installing MySQL, which was a very straight-forward process. I then downloaded the Apache HTTP server to my laptop, on top of which I was was going to run both MySQL and PHP. This was also fairly straight forward. It was when I tried to install PHP that I hit a wall.

I downloaded the latest version of PHP, 5.3.x, which, I later learned, is incompatible with Apache HTTP server 2.2, for whatever reason. I failed to realize this for a couple of reasons: 1) my six year old PHP guidebook wasn’t aware of this because Apache was still on version 2.0 and PHP on version 5.0.4 when it was published, so it would have no clue; and 2) because I was relying on the guidebook, I didn’t read the software documentation or download instructions, which clearly stated that PHP 5.3 didn’t work with the version of Apache I had installed.

The solution? Uninstall PHP and install PHP 5.2.x. This didn’t quite work either, however. When I tried to configure my new version of PHP with Apache server, I figured out I was supposed to download the “thread-safe” version of PHP–I had downloaded the non-thread-safe version. Therefore, I reinstalled PHP for a third time.

When I tried to configure the darned thing yet again, I still couldn’t get Apache to recognize my installation of PHP. I later found out that I was using illegal characters in the the PHP .ini file and the configuration settings for Apache; however, I had no clue what was wrong at the time and my efforts to diagnose the issue online were unsuccessful. I ended up reinstalling PHP yet again; this time using a pre-made installer instead of a ZIP file. Still no cigar.

It took me a full day to figure out what the problem was. I was using an online installation guide to try to get PHP up and running once I figured out my six-year-old guidebook wasn’t cutting it. However, when I was cutting and pasting configuration settings from the website to my computer, I was unknowingly taking formatted Unicode character with me.

For example, when I copied

doc_root = “C:Program FilesApache Software FoundationApache2.2htdocs”

into my configuration settings, I was copying formatted quotation marks with it. Instead of “”, I should have been using “”, the unformatted version of quotation marks. The use of these stylized quotation marks did not fit within the syntax needed for the configuration files. This later helped solve my problem of not being able to get MySQLi to work as well.

Anyway, I finally got Apache server on my laptop, with PHP and MySQL enabled, so my foray into moving to the dynamic web is finally moving again. Wish me luck.