Thursday, March 29, 2007

Email address validation with PHP

Ok this can be a tricky one....
I'm still new to PHP but I tried a number of different links and google searches and I tried these following examples and they didn't work:


$pattern = "/^w[wd]+(.[wd]+)*@w[wd]+(.[wd]+)*.[a-z]{2,7}$/i";
return preg_match($pattern,$email);


if (!preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/" , $email)) {
return false;
return true;

Obviously these are functions that I added to my own functions.php that I include in every PHP file I need them in - and the function would be called from said PHP file...... anyway I made sure I fixed all parentheses etc. on the stuff above but neither of them worked for me. They both said invalid email account.

Then I finally found one that works.... it's simple, I mean it just checks the format of the email address rather than opening a socket connection to the mail server to see if it exists. But it does the job for me

It's available at

Thursday, March 22, 2007

Libchart - Simple PHP chart drawing library

Like my previous post on PHP/SWF Charts, libchart is for drawing graphs, bar charts, pie charts etc. in PHP - but it doesn't use flash, it generates PNG files and as far as I know that's it but that should do the trick.

it's available at

PHP on the command line

If you want to run .php files from the command line,
eg. for file manipulation with no browser output or whatever, check out

To elaborate, I used to use freebasic or qbasic for programming little scripts that convert between one type of ascii data file and another. I used to read in a .CSV file into freebasic and check each line for commas and seperate the text - it was painful. Since I've learned a bit about PHP I can now use the Explode and implode commands in PHP - Explode will take apart a line of text that's seperated by commas, tabs, newlines, whatever you specify, and it will create an array for you with all the data. It makes the type of programming I did a million times simpler. For this reason I wanted to get PHP working on the command line. Now I can read in csv files and stick them on a MySQL database with ease.... ah how I love programming. I can also use the windows command-line "at" command to schedule the run of PHP. Of course this is all slightly different on a Linux box with "cron" being used instead of "at" etc. and the PHP command line parameters might be different. but you get the idea.

Oh yeah "implode" does the exact opposite of "explode".

Something to watch out for:
Check your PHP.ini - the line that says "extension_dir ="
For example, on my system I use uniform server, which I'll explain in another post.
I keep my uniform server on d:\uniserver so the line line in my php.ini said:


This meant that the extensions couldn't load from my current path where I was keeping my PHP files

How I got it to work was as follows (this will be different for you depending on where your copy of PHP is stored):
  1. I made a copy of my php.ini into my D:\ (anywhere will do)
  2. I changed the line to say extension_dir = "d:/uniserver/diskw/usr/local/PHP/extensions"
  3. Then if I'm in a directory and I have a PHP file called 1.php I could run PHP like so:
d:\uniserver\diskw\usr\local\php\php.exe -c d:\php.ini 1.php

It would echo out any echo stuff from within the PHP to the console, and will run any MySQL queries or whatever. It's nice. If you have any trouble with it, you can email me on

Qbasic for beginners!

Maybe I'm taking a step backwards here but I thought this was a very good resource site for the BASIC language. more specifically qbasic, but the beginner variable stuff etc. should be mostly good for freebasic and maybe even beginners VB. if you're interested in basic at all, check out the site below.

Free stock photos!!!

Check out the license for each individual image but I'm pretty sure if you want to use these photos on your website you can as long as you're not selling templates with the images contained therein... anyhow like I said, check the individual image license.

the site is

Tuesday, March 20, 2007

Using steam to cool computers!!!

"The exterior of the device is a copper sleeve that absorbs heat from a processor or a hard drive.

The interior consists of a series of vacuum-sealed chambers and channels containing small amounts of water. The water turns to steam, which then conducts the heat from the source to another component, such as an aluminum heat sink, that can dissipate the heat into the ambient atmosphere."

check out the full article here

Playing Unreal Tournament..... with your mind!!!

Thoze crazy scientisty people over at OCZ have figured out an interface for your pc that lets you control video games with your brain.

"OCZ´s latest brainchild is the Actuator, a device which tracks movement of your eyes, monitors brain waves and picks up facial muscle movements, it uses these recorded signals to link them to input commands on the computer, allowing you to play Tetris or even a first person shooter like UT2004."

check out the full article here

Props to Cully for sending me this link

Car PC - my other blog

My friend Gary and I are involved in a project to setup his car with an onboard PC with the following features:
  • Cheap GPS system
  • Dvd + multimedia / audio system
  • Wireless internet access (WIFI)
  • Full control over mobile phone
  • Reversing Camera
and lots more to come....

If you're interested in the idea fitting a PC or laptop in a car,
check out

Thursday, March 8, 2007

URL re-writing with Apache

If you value your website's security, it runs on Apache, and you don't know about URL re-writing you really should check out a really good article about URL re-writing here
There are also many other great reasons to read the article below.

Anyway, basically it shows you how turn this:

into this:

and this means that hackers don't even know if you're using ASP or PHP, which is a hurdle straight away. There are also many other fine uses. One pointed out to me by 2kreative is to redirect a .jpg url to a .php - this is useful if you want a dynamically created image for your forum signature, for example, and the forum image posting rules block .php - "haha nice one" I hear you say!!!! yeah well don't be using it for hacking purposes. that's evil.
By the way to quote 2kreative
"you should refer to apaches own documentation to see how in-depth it really is"

Dynamically resizing images {Mike Lopez}

Mike Lopez has some really good PHP tutorials on his blog.
Come to think of it he's got a great tech blog, full stop.

Here's one I find very handy for dynamically resizing images {bascially, it cuts down on bandwith and storage space by processing your images on the server end and just passing the thumbnail data to the user}
check it out here

PHP newbies - don't rush
How to setup your Apache / MySQL / PHP Development environment
Cheap Web Hosting 1
Cheap web hosting 2
Preventing Contact Form Spamming
PHP form to email script
Uploading files in PHP
Using PHP sessions
PHP Date tricks
Google Earth for Linux
How to setup samba and Autofs
Setting up Lan over internet
Orage - Mike's Calendar Tool of Choice
Really Free Ipods
Paypal Phishing
Free Cable TV via the Internet on Linux
Feedburner Wordpress plugin

he's got tons more on his blog but I didn't have time to index them all so check it out as soon as you can... unless you're not interested in this sort of stuff. but in that case, why are you even reading my blog? :-D

use PHP to create Flash charts and graphs

Do you know what's top class?
PHP/SWF Charts!!! that's what!!

Basically, you feed it info from your PHP, be it from a text file, database, whatever (use your imagination here folks) and then it makes lovely Flash charts for you!! And best of all, it's free (well, almost)
"The free, unregistered version contains all the features except for:

* Clicking a chart takes the user to the PHP/SWF Charts web site
* No displaying charts inside another flash file
* No technical support, and no product updates by e-mail"

But it's still top class.... the limitations above aren't that bad at all.
it's only $45 for a single license and with that you get a few more nice features (check the website for details)

Anyway, you can find it here

And Guess what? For once, I found this all by myself! me! yay!

Move over Google Desktop - here comes launchy

If you have vista you probably have no need for this as the start menu does it anyway but here goes:

Ok anybody who's heard of Google Desktop or uses it knows that it indexes all your documents and links and programs in a big database (this takes a long time initially), then when you want to find something fast you just type part of the name into Google Desktop and it finds the document or program quick-smart... However there are some debates ongoing about your privacy when you use Google Desktop. As far as I know there may be some info that gets sent back to google about your searching habits. But I've only heard rumours. I was far too lazy to research it so don't take my word for it - go check it out for yourself to be sure.

Here's the replacement ......

You can find it here

It's great... It has a funny name, it launches your documents, favourites, apps etc. and it doesn't take 50 years to index them all. You can be very specific about which folders to index (although I think that's possible also with Google Desktop) - It's better though, because at the start it only indexes the important stuff, and you can add as you need, whereas Google Desktop indexes everything by default (I think). Anyway one way or another, whether I can form coherent sentences or not, you should check it out.

As usual, 2kreative pointed this out to me. Dat fella sure finds some great stuff out dere.

Monday, March 5, 2007

Irish Webmaster Forum!!!

I didn't even know there was one of these - but you can check it out here