Intro to PHP R R
See my My PHP Applications.

Intro
phpinfo( )
escape characters
PHP Functions
Variables
PHP with MySQL
Connection to MySQL Server
Form Processing
count( )
Database Search
Arrays
fopen( )
Creating Images using GD library
Parsing other file types as PHP - with Apache
Sending Email with PHP without a mail server
How to generate a Word document
Variable variable


This intro to php will lean toward using it in conjunction with mysql for creating database driven websites. PHP is still relatively new, but the response to it has been astounding.

What can you use php for?

Basically, anything that cgi can do, can also be handled by php. Php has a huge advantage over cgi though because it executes faster and a lot easier to learn. Php can be used by itself or together with several database programs to create one killer website.

I'll get you started here, and you can then further your knowledge by reading more later.


To start learning php you either need to have an isp that supports php, or you can install a free copy on your windows/*nix machine. PHP can be run on your machine in one of two ways: as cgi, or apache module. Download it from php.net, or if you want a guide on installation and config info for Apache, PHP4 and MySQL on Windows, follow link. The installation and configuration is quite easy.
Return to Top
  • All php scripts begin with <?php and end with ?>, like this

    <?php

    STATEMENTS, STATEMENTS, STATEMENTS...

    ?>

    You can also configure your php.ini file to use

    <?
    ?>
    instead.

  • All lines of php codes end with a semicolon ;
  • One cool thing about php is that you insert the commands anywhere within your html codes, and I mean anywhere!
  • Comment lines are indicated by // for a single line comment, or /* */ for multiple line comments.

Let's start off with the classic Hello World!

Open Notepad and type the following into it

<?php

echo "Hello World!";

?>

You will notice that the statement following the echo command requires a pair of quotes. Echo is used to output something onto a web page.

An alternative to the echo command is printf. Printf( ) is a function, and we'll take a closer look later.

<?php

printf ("Hello World!");

?>

This does the same thing as the echo command, but you have to enclose the statement after printf in parenthesis, and then in quotes.

The statement itself is ended with a semicolon. If you forget to add the semicolon, you will receive an error.

Save the file above as hello.php3.
Open a browser and type http://localhost/hello.php3. Of course, your Apache server must be running, and hello.php3 must be saved in the web documents folder.

If you see a page with Hello World!, congratulations! you've written your first php script.


Return to Top
One function I find extremely useful is phpinfo(). Paste the following into Notepad and save as phpinfo.php.

Then go to http://localhost/phpinfo.php

<html><head><title>PHP Info</title></head>

<body>

<?php

phpinfo();

?>

</body> </html>

The first time I ran phpinfo( ), I felt like a bit too much info was being generated. If you happen to be security conscious, here's a way to disable the function...

Open php.ini and look for a line that says disable_functions =.

Put phpinfo() in front of it, and nothing will be displayed when you run phpinfo.php.


Return to Top
Now let's look at some useful examples of php coding. We'll create a form using html, and then look at the same code using php.

<html><head><title>form</title></head>
<body>
<form action="...url..." METHOD=POST>
<INPUT TYPE="hidden" value="Customer Info Form">
What is your First Name?
<INPUT NAME="first" TYPE="text">
Your Last Name?
<INPUT NAME="last" TYPE="text">
<INPUT TYPE="submit" VALUE="Submit"> </FORM> </body>
</html>

The above code will produce a form like this



What is your First Name?

Your Last Name?


No big deal there, just a normal html coding.

How about doing the same thing, this time using php? Here's what it'll look like...

<html><head><title>form</title></head>
<body>
<?php

echo "<form action="...url..." METHOD=POST>";
echo "<INPUT TYPE="hidden" value="Customer Info">";
echo "What is your first Name?";
echo "<INPUT NAME="first" TYPE="text">";
echo "Your Last Name?";
echo "<INPUT NAME="last" TYPE="text">";
echo "<INPUT TYPE="submit" VALUE="Submit">";
echo "</FORM>
";

?>
</body>
</html>

You see how we've used the echo command repeatedly to output our html statements. This is not good programming style, but just come along with me.


Return to Top

Using escape characters

If you've done programming before in C, Javascript, etc, you already know about escape characters. When you use certain characters in programming, your program interprets them as part of the code. Here's an example

<FONT COLOR="SILVER">

Here we have enclosed SILVER in quotes. This is the standard coding style in html.
If we translate this into php, we get

<?php

echo "<FONT COLOR="SILVER">";

?>

If however you try to run the above as a php script, you will get an error. That is because the quotes around SILVER are interpreted as part of the php command rather than individual characters. To correct this, we have to escape the quotes like this

<?php

echo "<FONT COLOR=\"SILVER\">";

?>

Now your script will run.

Think about this: You have a form on your site for gathering info that will be inserted into your database. You have no control over the characters that your users enter. Among such characters could be double quotes ("), and single quotes ('). If you allow such data to get inserted into your database without being escaped, I can assure you that the next time you go to retrieve the data, really wacky things are gonna happen and confuse the hell out of your php program. Ok so what is the solution?

Several solutions are possible

  • AddSlashes($str) can be used to automatically insert the backslash escape characters into a string.
  • magic_quotes_gpc When magic_quotes are on in your php.ini file, all ' (single-quote), " (double quote), \ (backslash) and NUL's are escaped with a backslash automatically.
  • Magic quotes runtime works similarly by automatically escaping all data obtained from reading files or databases.

Escaping characters is very common in programming, so get used to it.

Having learned about escape characters, what do we need to do to our earlier php script to make it run?

<?php

echo "<form action="...url..." METHOD=POST>";
echo "<INPUT TYPE="hidden" value="Customer Info">";
echo "What is your first Name?";
echo "<INPUT NAME="first" TYPE="text">";
echo "Your Last Name?";
echo "<INPUT NAME="last" TYPE="text">";
echo "<INPUT TYPE="submit" VALUE="Submit">";
echo "</FORM>
";

?>

We need to escape all the quotes like so

<?php

echo "<form action=\"...url...\" METHOD=POST>";
echo "<INPUT TYPE=\"hidden\" value=\"Customer Info\">";
echo "What is your first Name?";
echo "<INPUT NAME=\"first\" TYPE=\"text\">";
echo "Your Last Name?";
echo "<INPUT NAME=\"last\" TYPE=\"text\">";
echo "<INPUT TYPE=\"submit\" VALUE=\"Submit\">";
echo "</FORM>
";

?>

If you save the above with a .php3 extension and run it, you will receive no errors.


Return to Top

PHP Functions

What we have learned so far isn't very useful, but we will build on that.

Functinos are standard commands built into a programming language. You just take them as they are and use them. We've seen printf () earlier. That is a function. Whatever you put in the parenthesis is what you want the function to act on. So in our earlier example:

<?php

printf ("Hello World!");

?>

"Hello World!" is what we want our funtion to act on, and it is called the argument for the function.

More functions than you'll ever need at http://www.php.net/quickref.php


Return to Top

Variables

A variable is the opposite of a constant. A variable can have different values depending on what value is assigned to it at a given time. Variables are preceded by the $ sign. Example

$hello = "Hello World!"

What we just did is declare a variable $hello and assign it the value "Hello World!". Now everytime we use the variable $hello, it will spit out Hello World!. Don't be confused by the = sign. It has no mathematical significance. You would read the above as Assign $hello the value of "hello world!". If you want to use the mathematical equality, then the sign is ==.

Let's rewrite our earlier script using variables

<?php

$hello = "Hello World!";
printf ($hello);

?>

Note: when using variables with functions, you don't enclose the variable in quotes.


Return to Top

Using PHP with MySQL

PHP and MySQL are powerful programs and relatively easy to learn. You can run a complete suite of free apps that are as powerful as other programs that sell for thousands of $$$. An example is Linux/Apache/MySQL/PHP/SSL. If you're not familiar with MySQL, read my Intro to MySQL.


Return to Top

Connection to MySQL Server

Once you have your mysql server running, you can use php to retrieve or add data to the database.

The first step is to connect to the database

<?php

$connection = mysql_connect(server, user_name, passwd)

?>

The php function to use for connection is mysql_connect(), and we want that function to use server, user_name, passwd for connecting.

Server is your host, eg. localhost, cnn.com, or whatever your host may be.

user_name, passwd are parameters for a user you've created on the mysql server. Eg. a typical connection could be

<?php

$connection = mysql_connect("localhost", "root", "J149ycX2")

?>

A better way of writing the above would be

<?php

$server = "localhost";
$user = "root";
$pass = "J149ycX2";
$connection = mysql_connect($server, $user, $pass)

?>

Note that $connection is a variable. We could have used any name, eg. $connect, $dbaccess, etc.

Next you tell php what mysql database to use once connected by declaring a variable, eg.

$db = "customerinfo";

Your database is called customerinfo.

You then form your query on a table within the database. Let's say we have a table in customerinfo called music with four columns col1, col2, col3, col4, our query will be

$query = "insert into music values("col1","col2","col3","col4")";

When forming your query, you put quotes around the column values, and separate each column value with a comma.

Let's put all we have so far together

<?php

$server = "localhost";
$user = "root";
$pass = "J149ycX2";
$db = "customerinfo";
$connection = mysql_connect($server, $user, $pass);
$query = "insert into music values("col1","col2","col3","col4")";

?>

We now want to assign the result of our query to a variable $result, and the php function to use for that is mysql_db_query()

$result = mysql_db_query($db,$query,$connection)

The result of your query is now stored in $result. Let's say after inserting the values into customerinfo, you want the table to be displayed on a webpage, what you do is form a SELECT query, and then print the result using echo or printf ().

Before we go further, let's see how we can collect info from a normal html form, and then use php to insert such info into a mysql database.

Assuming you have a mysql table called music, with columns called first, last, address. You want a visitor to your webpage to be able to add info to your database through a form. Here's how to do it.

Create a normal html form

<html><head><title>Form Processing</title></head>
<body>
<form action="form.php3" METHOD=POST>
<INPUT TYPE="hidden" value="Customer Info Form">
What is your First Name?
<INPUT NAME="first" TYPE="text">
Your Last Name?
<INPUT NAME="last" TYPE="text">
Your Mailing Address?
<INPUT NAME="address" TYPE="text">
<INPUT TYPE="submit" VALUE="Submit"> </FORM>
</body>
</html>

There's nothing special here, it's just a normal html file.

Inside <form action="form.php3" METHOD=POST>, we have indicated the name of a file - form.php3 as the file we want to use to process this form. form.php3 is a php file that we will create, and it will take all the info entered into our form, and insert it into the database. For this to work, all our form fields must have a name attribute. It is the name attributes that form.php3 will be looking for once it is called by our html form.

Those name attributes automatically become variables. So in the above form we have the attributes first, last, address. When they are passed to form.php3, they become $first, $last, $address. We can then form a mysql query based on the variables from the form. First save the above as a html file. Call it form.html

Now let's create form.php3. We will take what we did before and modify it to fit our present need.

<?php

$server = "localhost";
$user = "root";
$pass = "J149ycX2";
$db = "customerinfo";
$connection = mysql_connect($server, $user, $pass);
$query = "insert into music values("col1","col2","col3","col4")";

?>

It should look like this

<?php

$server = "localhost";
$user = "root";
$pass = "J149ycX2";
$db = "customerinfo";
$connection = mysql_connect($server, $user, $pass);
$query = "insert into music values('$first','$last','$address',id)";

?>

You can see that we have used apostrophes instead of quotes around the variables $first,$last, and $address. That is standard. You use quotes around a string, apostrophe around variables, and no quotes around numeric values (eg. the number 247 will have no quotes). The other thing we did is add a fourth field called id. We did this because id is our primary key. If you're here learning to use php with mysql, you already know about primary keys.

Now to get your form to work,

  • use the right values for $user and $pass. $user must have "write" previledge to your database.
  • save the file as form.php3 in the same directory as our form.html. That directory must be readable over the web, so put the files in the web documents directory.
  • make sure mysql server and apache are both running, then fire up form.html with http://localhost/form.html.
  • test the form.
If you get no error when you submit the form, congratulations! You now have a database driven website.

You could receive any number of errors, ranging from syntax errors, to typos, to improper GRANT access to your $user. Where you look to solve this error will depend on what the error says.

Let's move on.

If php successfully added the data from the form to your database, you will receive no response. The only time you get a response will be if an error was encountered. So we're now going to make our code smarter by making it give us feedback on what it's doing

<?php

$server = "localhost";
$user = "root";
$pass = "J149ycX2";
$db = "customerinfo";
$connection = mysql_connect($server, $user, $pass) or die("Cannot connect");
$query = "insert into music values('$first','$last','$address',id)";
$result = mysql_db_query($db,$query,$connection) or die("Error in query");
echo "Data successfully added to $db";

?>

If it is unable to connect or if it encounters an error while querying the database, you get a response. Normally, once an error occurs, php will stop processing the script (unless you include if-else statement). Hence, if you get a response that the operation was a success, it means no error was encountered.

The form we've created is far from perfect. For instance, what happens if someone tries to send an empty form, or enters letters where a zip code should go... Form verification can be done easily in various ways. I'll write about that some other time. Search the web to find a tutorial now.


Return to Top
Let's look at another example script. This one will display the number of records in our table.

<?php

$server = "localhost";
$user = "root";
$pass = "J149ycX2";
$db = "customerinfo";
$connection = mysql_connect($server, $user, $pass) or die("Cannot connect");

//form your query
$query = "select count(*) from music";

// run the query on the database
// assume the database is named "music"
$result = mysql_db_query($db,$query ,$connection);

// assign the result to a variable
$counter = mysql_result($result,0);

// and display it
echo "Database contains $counter records";
?>

count( ) is the function we used above to get the number of records in the table, and then assign the result of the query, $result to a variable $counter. count(*) means count every record in the table and come up with a numeric value. Finally we display the number of records.


Return to Top

Database Search

If you've ever thought of an easy way to search your site, today is your lucky day. I'll show you how to use php for searching a database driven site. Usually, a form field is placed on a page, a visitor types in keywords and hits a button, and results are displayed moments later.

We're going to create this in three steps. First, we'll create the form that one will type keywords into. Second, we'll setup a php query on mysql. Third, we'll display the results of the query on a page.

<html><head><title>PHP Info</title></head>

<body>

<form action="search.php3" METHOD=POST>
<INPUT TYPE="hidden" value="Customer Info Form">
Keywords
<INPUT NAME="keywords" TYPE="text">
<INPUT TYPE="submit" VALUE="Submit"> </FORM> </body> </html>

Save the above as search.html.

Now we're going to create search.php3.

<?php

$server = "localhost";
$user = "root";
$pass = "J149ycX2";
$db = "customerinfo";
$connection = mysql_connect($server, $user, $pass);
//form the query on $db and table called music

$query = "select $search from music where $search LIKE '%$search%';
//run the query on the database
$result = mysql_db_query($db,$query ,$connection);

?>

LIKE '%...%' is a mysql string comparison function. $search is what the visitor to your webpage types into the search form. $search is then compared against all the data in table to see if there's a match. If there's a match, mysql returns the results found, which will then be displayed on the webpage through php.

How mysql does the comparison depends on where you place the wildcard character %. For instance, you could have

LIKE '%$search'. This would match all words that has the $search ending. On the other hand, if you used

LIKE '$search%', that would match all words beginning with $search. The safest search method will be to use

LIKE '%$search%', which will match all occurences of $search, whether at the beginning, middle, or end of a word. But that would return a lot more results, and probably take longer to search.


Return to Top
Before we go to the last step, let's talk about arrays.

Arrays

Up until now, we've only dealt with single results, eg. $counter=47. Usually however, your query will return multiple results that you would like to display on a page. You need arrays for that.

The handling of arrays is simple. You declare a variable that will hold all the values in the array

$cars = array ("pinto","honda","lexus","zhiguli","bmw");

$cars is an array variable which contains the values "pinto","honda","lexus","zhiguli","bmw". Each element in the array is assigned an id starting from 0. You can then access them by using the variable name followed by a number in square brackets like this

$cars[0], $cars[1], $cars[2], etc.

In this case, $cars[0] will be pinto, while bmw will be $cars[4].

$cars is an array variable which contains the values "pinto","honda","lexus","zhiguli","bmw".

Another way of specifying an array is as shown below

$cars[0] = "pinto";
$cars[1] = "honda";
$cars[2] = "lexus";
$cars[3] = "zhiguli";
$cars[4] = "bmw";

My reason for introducing arrays is because we're going to need it to display the results of our search. If the search returns more than one record, the only way to display it will be with arrays.

Let's say our query on the music table

$query = "select $search from music where $search LIKE '%$search%'";

returned the values Britney Spears, Britney Sparrow, Spearhead, J. Spencer, we can display the results on a page as follows:

<?php

if (!$result) { echo "No results were found with your search words. Try again with other keywords";

} else { $eachrow = mysql_fetch_array($result); for ($j =0, $j < sizeof($eachrow), $j++); echo "$eachrow[$j]";

}

We have a couple of new things here. Let's recap

First we connect to mysql server using

$connection = mysql_connect($server, $user, $pass);

Then we form the query $query on $db

$query = "select $search from music where $search LIKE '%$search%';

Next we run the query on the database, and store the result in $result

$result = mysql_db_query($db,$query ,$connection);

Because our search may return multiple results, we store the result in an array $eachrow using the function

$eachrow = mysql_fetch_array($result);

Finally we count the rows and echo the result

for ($j = 0, $j < sizeof($eachrow), $j++);

echo "$eachrow[$j]";

Are you with me so far? Great!

One of the methods of counting is the FOR statement. If you've done programming before, eg. in C, then you know. To make sure that all the rows are counted, PHP has another function sizeof( ) function which we've used here. So let's now put everything together.

<?php

$server = "localhost";
$user = "root";
$pass = "J149ycX2";
$db = "customerinfo";
// Connect to the server
$connection = mysql_connect($server, $user, $pass) or die("Cannot connect");

// form the query on $db and table called music
$query = "select $search from music where $search LIKE '%$search%';

// run the query on the database
$result = mysql_db_query($db,$query ,$connection) or die("Error in query");

// If search finds no match
if (!$result)

{

// Print the following

echo "No results were found with your search words. Try again with other keywords";

}

// If there's a match
else {

// store the result in the variable $eachrow as an array
$eachrow = mysql_fetch_array($result);

// count the rows
for ($j =0, $j < sizeof($eachrow), $j++);

// print the result
echo " <table><tr><td>$eachrow[$j] . "</td></tr>" ";

echo "</td></tr></table>";

}

?>

So now how do we format the output, so the result looks good on the webpage? Well, that should be an easy task with table tags. As you probably know, the period . is what is used in php to concatinate data. That's why we've used the table tag.

Save the file as search.php3 in the same folder as search.html. Both files must be in your web space.

There seems to be endless possibilities to what you can use php to create. It can be used for user authentication, where people visiting your website can register and then log in on subsequent visits. Anyone who registers get added to the mysql.user database. When the user wants to log in, the info she provides in a form is compared to what is available in mysql.user database, then access is granted or denied. A user can modify personal info anytime, all without intervention from you.

PHP can be used to create shopping carts, online auctions, discussion forums, Guest Books, file uploaders, mailing lists, search engines, FTP, webpage menus, barcharts, clocks, even dynamic images, and the list goes on and on. Personally, I've created a Classified photo ad system, a free-for-all links script, and a webpage maker (user enters several info in a form and html code is automatically generated). I work on improving the scripts whenever I can find the time. You can see some of the scripts here, but only when I'm online.

Also, learn how to read and write to a flat text file, instead of using a Relational Database. Don't miss this important tutorial.

What I've presented here will get you started on the road to becoming a php programmer. Get yourself a good book, search the web for great tutorials, join mailing lists, and frequent discussion forums for when you need help.


Differences between single quotes ' ' and double quotes " "

Double quotes will interpret your statement,
Single quotes will output statement as written

Eg.

$value = "63 + 19"; //Will store 82 in $value
$value = '63 + 19'; //Will store 63 + 19 in $value


Believe it or not, php can be used to generate images on the fly. Such images are in the form of gif, jpg, bmp, and png formats. For such image generation scripts to run, you have to compile php with the GD library, or if you're on win32 platform, get php_gd.dll with installation instructions.
Return to Top
Parsing other file types as PHP - with Apache

If you're using Apache server, You can parse certain file types as PHP. If for some reason you want to conceal the scripting language you're using, you can do so. So, files ending with .html can be used in the same way as files ending with .php.

Add this line of code to the Apache httpd.conf:

AddType application/x-httpd-php .html

Now you can put php code in a file, name it with a .html extension, and it will get parsed as a php file.

What happens if we did this instead?

AddType application/x-httpd-php .asp

This would allow you to put php code in a file, name it with .asp extension, and it'd be passed as php.

Basically, you can use any extension for your files, and they'll get parsed as php. For example, I can give a file the extension .rich, then add this to apache

AddType application/x-httpd-php .rich

A file such as index.rich will get parsed as php. Neat isn't it!

If you're thinking what the point of all this is, think about hackers. The first step a hacker takes is to know what you're running. If he can't detect that visually, he may not want to go into the trouble of using other tools to find out.

To truly go incognito, change this line in your PHP.ini file

expose_php = On to expose_php = Off.


Return to Top
Sending Email with PHP without a mail server like Sendmail

Configure php.ini
Change:

; For Win32 only.
SMTP = localhost

to

; For Win32 only.
SMTP = mail.yourISP.com

Sometimes, the above config will be

; For Win32 only.
SMTP = smtp.yourISP.com

Ask your ISP, or take a look at how Outlook Express is configured.

Next, change:

; For Win32 only.
sendmail_from = me@localhost.com

to:

; For Win32 only.
sendmail_from = YourName@YourSite.com

Save php.ini, and restart Apache.

Let's test if this really works.

Create a file called: phpmail.php and paste the following into it:

<?php

$myname = "Richard";
$myemail = "richard@ValidDomain.com";

$contactname = "Mister Contact";
$contactemail = "ValidEmail@Valid.com";

$message = "Testing php email using php's MAIL() function.";
$subject = "PHP email test...";

$headers. = "MIME-Version: 1.0\r\n";
$headers. = "Content-type: text/html; charset=iso-8859-1\r\n";
$headers. = "From: ".$myname."<".$myemail.">\r\n";
$headers. = "To: ".$contactname."<".$contactemail.">\r\n";
$headers. = "Reply-To: ".$myname."<$myreplyemail>\r\n";
$headers. = "X-Priority: 1\r\n";
$headers. = "X-MSMail-Priority: High\r\n";
$headers .= "X-Mailer: Just My Server";

mail($contactemail, $subject, $message, $headers);

echo "Your mail was sent successfully!";
?>

As you can see, the email addresses we've used above are not valid. Use valid values.

Save the file under the Apache documents folder.

Open up a browser and run the file. http://localhost/phpmail.php



Return to Top
You can use the COM class in your php script to generate a .doc file as follows:

// start word
$word = new COM("word.application") or die("Unable to start Ms Word");

// Bring Ms Word forward. If you want see the Word interface the value must be '1' else '0' $word->Visible = 0;

//$contents will be the string you want to convert to a Word document
$word->Documents->Add("$contents");

$word->Documents[1]->SaveAs("filename.doc");
//close word
$word->Quit();

//free the object from memory
$word->Release();
$word = null;
Learn more about COM.



Return to Top
The first time I heard of variable variable, I quickly concluded that some people just love to complicate issues. My thought then was that a variable variable was just another way of assigning a name to a variable. That was my thought until I ran into a peculiar coding issue, one where I needed to do multiple database up updates at once.

Here is my case.

  • I have a loop. This loop updates mysql db 3 times.

    for($i=0; $i<3; $i++){

    $query = "update ... set ...=... where ...='$lastInsertID'";

    }

  • $lastInsertID is a variable dynamically generated from a mysql db insert within the loop. This insert only occurs once in the loop. Since it only occurs once, I needed a way to maintain its value through the life of the loop.

    for($i=0; $i<3; $i++){

    $query = "insert into ... values(...)";

    $lastInsertID = mysql_insert_id();

    $query = "update ... set ...=... where ...='$lastInsertID'";

    }

    The code above will do 3 inserts and generate 3 different $lastInsertID. But we want only one, hence I did this:

    for($i=0; $i<3; $i++){

    include_once("insertQueryFile.php");

    $query = "update ... set ...=... where ...='$lastInsertID'";

    }

    the insert code is now located inside the include(). Unfortunately, this means that $lastInsertID will only be available the one time that the include runs. The value of $lastInsertID will be zero on subsequent iterations. So, our goal now is to find a way of maintening $lastInsertID through the life of the loop. The is where variable variable comes in.

    for($i=0; $i<3; $i++){

    include_once("insertQueryFile.php");

    $$lastInsertID = $lastInsertID;

    $query = "update ... set ...=... where ...='$lastInsertID'";

    }

    Notice the extra $ sign in front of $lastInsertID? That make $$lastInsertID a new variable in its own right.

    To make my code work, I now called the variable variable, instead of just $lastInsertID. Here is how to call a variable variable: ${$lastInsertID}. The value of ${$lastInsertID} stayed constant for the life of the loop.


    Send me a feedback on this tutorial, so I can improve on it. Thanks.


    Home | Comments, suggestions? | Another Angle