Bj wrote:
Try rewriting:

# Verify if username already exists
# 1. Build the query
$query = "SELECT_COUNT(*) AS ucount " .

Where did the underscore come from? Should be a space.


  "FROM book_mydb.members " .
  "WHERE members.username = " .
  " '{$_POST['username']}' ";
# [Incidentally I have no idea what the { } curly
# brackets are doing here...]

The curly brackets let you put assoc arrays inside double quotes and not confuse the parser. They mark the beginning and end of the variable. As long as we are using dot to concatenate the strings we can leave {} out:


$query = "SELECT COUNT(*) AS ucount " .
   "FROM book_mydb.members " .
   "WHERE members.username = '" . $_POST['username'] . "' ";

Note the single quotes needed for SQL (to the right of = ) have been shifted to neigboring stings.

It's not even necessary to use all those double quotes, this will work just fine:

$query = "SELECT COUNT(*) AS ucount
          FROM book_mydb.members
          WHERE members.username = '" . $_POST['username'] . "' ";

More than ever I am
convinced you are trying to learn from someone who is an incompetent
programmer, as well as a poor teacher and careless typist.

I agree. There is a lot of badly written code floating around the net that just gets duplicated over and over again.


Sheila

PS: I teach Intro to PHP at EclecticAcademy.com Teaching someone else to code is not easy. I mainly try to provide examples of what I consider good programming practices and hope the designers that take my class become comfortable enough with PHP to make minor changes to scripts. I hope to add a PHP/MySQL class but it's a lot of work writing good lessons.

--
Sheila Fenelon
http://www.shefen.com



____ • The WDVL Discussion List from WDVL.COM • ____
To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED] Send Your Posts To: [EMAIL PROTECTED]
To set a personal password send an email to [EMAIL PROTECTED] with the words: "set WDVLTALK pw=yourpassword" in the body of the email.
To change subscription settings to the wdvltalk digest version:
http://wdvl.internet.com/WDVL/Forum/#sub


________________ http://www.wdvl.com _______________________

You are currently subscribed to wdvltalk as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]

To unsubscribe via postal mail, please contact us at:
Jupitermedia Corp.
Attn: Discussion List Management
475 Park Avenue South
New York, NY 10016

Please include the email address which you have been contacted with.



Reply via email to