Nov 14th 08
Getting The Last Auto Increment Field With PHP
On many occasions you need to find the value of the last auto increment field inserted into a MySQL table. For example within my Content Management System if someone creates a new web page and saves it the user is taken back to edit this new page. In order to do this I must retrieve the value of the last auto increment field inserted into the database. To do this I use the php mysql_insert_id();... read more
Nov 11th 08
Detecting Mobile Devices with PHP
I have been using a great function written by Andy Moore on one of my personal sites that I run for my friends to detect Mobile Phones with php which worked a treat until a friend of mine bought himself a nice shiny iTouch and found the site still redirected him to the sites dedicated mobile pages. After the jealously of finding out my friend had a nice iTouch subsided I set to work to implement the detect... read more
Oct 20th 08
Connecting to MySQL with PHP
Connecting to a mysql database is pretty easy using php as it gives you all the commands you need in order to do it. This example is a basic way to do, there are other methods but I found this way useful when I was just starting out! Here is an example of connecting and quering a mysql... read more
Oct 20th 08
Basic PHP – Assigning Values to Variables
Adding values to php variables is simple as the following examples shows The example code above will add the value Bobby to the variable $name and 30 to the variable age. You can print the value of the variable out to the browser by using the echo statement as follows. Further to this we could add this html to a page. Hi my name is ; and my age is This will print out Hi my name is Bobby and my age is... read more
Sep 16th 08
Basic PHP – The Hello World Program
This is a simple program to start you off using php scripting. This small program prints out “Hello World” to your browser using php rather than plain html. Type the following into a text editor and save the file as test.php If you point your browser to this file you will see Hello World! displayed in your browser, well done you have just completed your first php program! PHP Common... read more
