PHP Installer doesn't ask for web server

If you are having the problem that the PHP Installer MSI is not asking for your web server type and therefore not updating your server configuration or not installing the correct libs such as "php5apache2_2.dll" then you are probably using the wrong MSI.

All of the MSI installers are on the page. You do not want to use the VC9 installers. You need to use the VC6 x86 Thread Safe installer. This is usually the last option, per version.

The link to the latest safe MSI is here: PHP 5.3 VC6 Thread Safe MSI

Fix "A connection attempt failed because the connected party did not" PHP error

I recently upgraded my PHP version to 5.3 and afterwards could not connect to MySQL. I was getting the following error in my PHP error log: PHP Warning: mysql_connect(): [2002] A connection attempt failed because the connected party did not (trying to connect via tcp://localhost:3306)

The solution is to do with Windows enabling IPv6 support while MySQL does not support this yet. 'localhost' is being converted to ::1 instead of, the solution to this is simple.

Go the the following directory: C:\Windows\System32\drivers\etc

Allow yourself full access to the hosts file by right clicking it and clicking properties.

Next go to the security tab and click the big "Edit" button.

Click on the "Users" group. Below this check the "Full Control" box and then save the changes.

Now that you have access to the file, open the hosts file with a text editor such as notepad.

Comment out the ::1 line with a # so the file will look something like:

# Copyright (c) 1993-2006 Microsoft Corp.
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
# For example:
#          # source server
#              # x client host       localhost
#::1             localhost

Once you are done, save the file and try to access your PHP page again that is using MySQL. It should work immedietley.

Highlight textfield onclick

To highlight the value of a textbox when the user clicks on it, simply use the built in JavaScript function "select()"


<input onclick=";" type="text" name="title" value="Title...">

mod_rewrite on localhost

I have recently been playing with mod_rewriting my web application URLs. I find that they worked perfectly on my live host but just wouldn't work on localhost.

This solution works for me: You have to open the httpd.conf Apache configuration file.

Locate this line and remove the "#":

 #LoadModule rewrite_module modules/

Finally search the file for "AllowOverride None".

This phrase will appear 7 times in the file, you want the second one and change the "None" to "All".

The comment above the line is:

# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
#   Options FileInfo AuthConfig Limit
AllowOverride All

PHP $_SERVER example list

A list of all the PHP $_SERVER global variable arguments with example output.

ArgumentExample Output
PHP_SELF /blog/article.php
SERVER_SOFTWARE Apache/2.2.15 (Win32) JRun/4.0 PHP/5.2.13
REQUEST_TIME Request start time: 1280149029
QUERY_STRING id=10&user=foo
DOCUMENT_ROOT /path/to/your/server/root/
HTTP_ACCEPT text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
HTTP_ACCEPT_CHARSET ISO-8859-1,utf-8;q=0.7,*;q=0.7
HTTP_USER_AGENT Mozilla/5.0 (Windows; U; Windows NT 6.0; en-GB; rv: Gecko/20100625 Firefox/3.6.6 ( .NET CLR 3.5.30729)
REMOTE_HOST Client server's host name
SCRIPT_FILENAME /path/to/this/script.php
SERVER_SIGNATURE Version signature: 5.123
SCRIPT_NAME /blog/article.php
REQUEST_URI /blog/article.php?foo=bar

Referenced from $_SERVER manual.

How a website will benefit your business

Do I Need a Website?

In a few short years all businesses will have a website. In fact it is quite uncommon to see a business without a website even these days. I will sum up in a few short points why having a website is a great addition to your business and will pay for itself in the long run.

Free Advertising

Once your website is built and online it acts as free advertising. Nearly 1.5 million Google searches are done every minute according to recent statistics. This means there are literally thousands of people out there able to find your website, without even beginning to consider other search engines such as Yahoo or Bing.

Inspire Trust

A good looking website inspires a lot of trust in potential customers. Many people browse the internet to research possible choices when looking for a product or service. Having a professional user-friendly website can make all the difference between making a sale and giving business away to your competitors.

New Communication Channels

A website offers a whole new level of communication between your company and your customers. Many people do not enjoy speaking on the phone to a company; your website will offer alternatives such as email, address to mail or even live chat online.

A website can even be used to let customers type in how they feel and leave comments which you can reply to, letting the customer know you care for them and value their custom.

Keep Customers Up To Date

A website can be used to launch important news announcements about your company straight to the public through your blog, news feeds or even a monthly newsletter.

Time is Money

A well used cliché in the business world – but often this is proven true. Having a website can improve business efficiency a hundredfold. Instead of having scraps of paper lying around detailing invoices and day to day notes, store these online where they are always available to you, in your office or at home.

Once you have a website helping you run the business you can do all sorts of interesting things such as run reports on sales, backup client information and provide news updates to your staff.


To wrap all of this information up for you, the main point of a business website is to pull in more customers and sell more of your product. Websites are quick and easy to setup; once they are online your customer base will begin to grow immediately, with the handy side effects of bringing in more money and growing your business quicker than you thought possible.

Installing syntaxhighlighter error: XregExp not defined

I recently installed syntaxhighlighter. The useful JavaScript tool for professional formatting of code blocks for blogs etc. by Alex Gorbatchev.

I followed the installation guide properly adding the shCore.js and brush scripts I needed. I also included shCore.css and shThemeDefault.css style files but kept receiving the same JavaScript error: XregExp not defined in shCore.js

It turns out after a lot of trial and error that you do not use the JavaScript files in the "/src/" folder of the download files. These do not work. You must use the 3 files with the same name in the "/scripts/" folder, specifically:

  • shCore.js, 
  • shLegacy.js 
  • shAutoloader.js

Find current URL using PHP

If you've ever wanted to find the complete current URL of the page you are on using PHP, it's easy using PHP's built in $_SERVER global variables.


To break it down, we start with a string writing the "http://".

We then use the period (.) character to concatenate on the server name. $_SERVER['HTTP_HOST'] returns the name of the server. e.g. 'localhost' or ''.

Finally we concatenate on $_SERVER['REQUEST_URI'] using the period character again. Request URI returns the current page you are accessing on the server e.g. '/blog/view.php'

To show a URL without the 'http://', for simpler presentation simply don't add this string at the start.


© Blake Simpson, 2012 – 2018