Nope, this doesnt work... it says Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/neo/public_html/studio/new/basket/check.php on line 25

Also,

Also, you're making one of the cardinal mistakes of PHP with your usage of printf(). Instead of using printf(), you should just be using string parsing or concatenation. For reference, check out the Top 21 PHP Programming Mistakes - Part I.

frogrocker wrote:Nope, this doesnt work... it says Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/neo/public_html/studio/new/basket/check.php on line 25

My code assumes that you've already connected to the database and performed a query using mysql_query() and have passed the results to $results before doing mysql_fetch_array(). If you have not done this, then $results isn't defined, so you get the invalid resource error. The first part of Example 2 in the documentation will help you with this, but I recommend finding and reading good PHP+MySQL tutorial online before tackling databases.

frogrocker wrote:

Also, you're making one of the cardinal mistakes of PHP with your usage of printf(). Instead of using printf(), you should just be using string parsing or concatenation. For reference, check out the Top 21 PHP Programming Mistakes - Part I.

Please explain...

Did you read the article that I linked to? That gives a better explanation than I could come up with. Please read it thoroughly and if you still don't understand, come back and let me know.

frogrocker wrote:1. What's with all the dots?2. How does $mailcontents seem to have more than one value..

1. The documentation is always useful for this sort of question. Please use it to answer your questions as frequently as possible. But I'll indulge you anyhow. In php, . is the concatenation operator, and .= is the concatenating assignment (append) operator. They are the operators for joining two or more strings. To demonstrate:

$a .= $b // This appends the contents of $b to the end of $a // The above is essentially a shortcut for $a = $a . $b; echo $a; // This will also print "unitedstates"?>

This is very basic PHP and you will need to know it to create all but the simplest scripts in PHP. I recommend that you read a good basic PHP tutorial. Webmonkey has a tutorial that looks reasonably good. Once you've gone through all of these exercises, you may want to read the documentation for the String type. This will answer your second question, as well, but I'll take a stab at it anyhow.

2. $mailcontents does not contain more than one value. It contains a single string. When denoting a string using double-quotes (e.g. $mystring = "something";), you can also include special characters. The characters "\n" represent the "newline" character, which is what split the $mailcontents into several lines when it sent the e-mail. To demonstrate:

<? $a = "this is\nthree\nseparate lines"; echo $a; /* The output will look like this: ---------- this is three separate lines ---------- Using the concatenation operator as I demonstrated above, you can also rewrite the above in a slightly more readable manner, and it is a good idea to do so: */

$b = "this is\n" . "three\n" . "separate lines"; /* Make note of the dots at the end of each line (except the last). The variables $a and $b now have identical contents (you can test this using "if($a === $b) ..."). */?>

So you see, it has converted each instance of "\n" into a line break. It's important to note, however, that when you output to an HTML file and view that file in your browser, newlines will be ignored and the above would look like "this is three separate lines". To produce a line break in HTML, you must use the HTML tag "<br />" (the trailing slash is for XHTML compliance). So to make the above appear as three lines in your browser, you should instead make your code like the following:

Ah, I'm glad you've got a book and you aren't just going at it blind. I've never read any of the SAMS books, but I've always found it easier to learn something when I have a real book in my hands that I can flip through. Good luck.