PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 24th, 2000, 07:46 PM
mmccue mmccue is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2000
Posts: 43 mmccue User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 14
Send a message via ICQ to mmccue
I cannot figure out what I am doing wrong... I am trying to create a "register" page for my site where the user fills in his desired username, real name, password, and his email address... for my example I will be passing $username and $email from a previous form..

register.php3
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
$query1 = "SELECT username FROM tblusers WHERE username='$username'";
$query2 = "SELECT email FROM tblusers WHERE email='$email'";
//
// here's the problem part
//
$user_prev_a = MYSQL_QUERY($query1);
if ($user_prev = MYSQL_FETCH_ARRAY($user_prev_a)) {
$userexists = 1;
}
$email_prev_a = MYSQL_QUERY($query2);

if ($email_prev = MYSQL_FETCH_ARRAY($email_prev_a)) {
$emailexists = 1;
}

[/code]

What I'm trying to do is say "Query for the provided username, if it exists in the database, then set $userexists to 1", but what I am getting is the following error :

<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
Warning: 0 is not a MySQL result index in /www/yoursite/register.php3 on line 84

Warning: 0 is not a MySQL result index in /www/yoursite/register.php3 on line 91
[/code]


Any help on how to accomplish this would be greatly appreciated.

Mike

Reply With Quote
  #2  
Old April 24th, 2000, 09:59 PM
Kyuzo Kyuzo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 1999
Location: Annapolis, Maryland US
Posts: 113 Kyuzo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 14
Something seems to be the matter with your query, either the table name is wrong or the column name(s) is/are incorrect.

Use
else
print(mysql_error());
after both IF statements to check the error message.

Other than that, your code seems to be O.K.

Reply With Quote
  #3  
Old April 25th, 2000, 03:03 AM
Shiju Rajan's Avatar
Shiju Rajan Shiju Rajan is offline
.Net Developer
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2000
Location: London
Posts: 987 Shiju Rajan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 26 m 22 sec
Reputation Power: 14
Send a message via MSN to Shiju Rajan Send a message via Yahoo to Shiju Rajan

yea,

The code is correct it seems.

i think field name must have written wrong.or just check it out whether values are passing correct to the query.

$result = mysql_query("SELECT * FROM tblusers WHERE username='$username'");

if (mysql_num_rows($result) == 1)
{
$userexists = 1;
}

$result1 = mysql_query("SELECT * FROM tblusers WHERE email='$email'");

if (mysql_num_rows($result1) == 1)
{
$emailexists = 1;
}




------------------
SR -
shiju.dreamcenter.net

Reply With Quote
  #4  
Old April 25th, 2000, 05:37 AM
Obsidian Obsidian is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Posts: 3 Obsidian User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Just a thought.... I don't know if this makes any difference as I always code this way, but I add the final semicolon to the statement. This would make your select clause appear thus :

("......where fred=37;");

....fred=37[;]"); the semicolon in the Sq brackets is the chap I always add (without the brackets of course).

URL

------------------


GE @ Obsidian Software

Reply With Quote
  #5  
Old April 25th, 2000, 05:43 AM
mmccue mmccue is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2000
Posts: 43 mmccue User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 14
Send a message via ICQ to mmccue
Thanks for the help peoples... I think what I was really looking for was the MYSQL_NUM_ROWS statement to determine whether or not a record existed...

Oh, and Shiju, I'm still working on the login script... with this out of the way finally, I'll definitly have it done by this weekend

Later,
Mike

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > the "if" statement has me by the .....

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap