Hi Joseph

First a dsiclaimer, in view of my closing remark, I apologise in advance for
any inadvertent slips in the following code... :-)

> This:        '{$_POST['username']}' "),0);  in the SELECT
> query is the fault with the other problem, but I cannot work
> out what is wrong with it.   So far I haven't discovered a
> reference or an example which makes the problem clear,
> let alone the solution.

I'm sure very few experienced programmers would write a complex statement
like that, and definitely not in an example for beginners to follow.  Far
better practice is to break things down into simple steps rather than string
them together into an indecipherable lump (er... let's leave regular
expressions out of this for now...)

Try rewriting:

# Verify if username already exists
# 1. Build the query
$query = "SELECT_COUNT(*) AS ucount " .
  "FROM book_mydb.members " .
  "WHERE members.username = " .
  " '{$_POST['username']}' ";
# [Incidentally I have no idea what the { } curly
# brackets are doing here...]
# To help debugging, display the query at this point
# so you know what you are asking the db
print "Query is : $query<br>\n";
# 2. Execute the query:
$result = mysql_query($query);
# Check for a mySQL error:
if mysql_error() > ""
  print "Error: " . mysql_error() . "<br>\n";
else {
# 3. Get the result of the query
  $_ucount = mysql_result($result,0);
}

Note that I wouldn't ever use mysql_result myself, as I prefer (as good
programming!) mysql_fetch_row and mysql_fetch_array.  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.

There are some great php and mySQL tutorials on WDVL as well as DevShed

But hey, who needs tutorials when php and mySQL are so easy.  Why not just
find a real project and learn while you do it.


____ • 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