Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-30-2013, 12:17 PM   PM User | #1
zubat
New Coder

 
Join Date: Dec 2011
Posts: 15
Thanks: 1
Thanked 0 Times in 0 Posts
zubat is an unknown quantity at this point
Check if value exist in mysql

PHP Code:
$sql mysql_query("SELECT email FROM users WHERE email ='$email'");
                                    
if(
mysql_num_rows($sql) != 0)
{
echo 
'<font color="ff0000"><li> Email exist!</font>';

So my problem is, that even if i write an email that i know exist in the database it let me through. I got the config.php include a bit up in the code so the database connection is no problem.

//Zubat
zubat is offline   Reply With Quote
Old 01-30-2013, 12:37 PM   PM User | #2
AndrewGSW
Senior Coder

 
Join Date: Apr 2011
Location: London, England
Posts: 2,120
Thanks: 15
Thanked 354 Times in 353 Posts
AndrewGSW will become famous soon enough
mysql_num_rows returns the number of rows or false. The docs. So you should test against > 0.

NB
The mysql library is deprecated - there is a stark warning against its use on the docs page - and will be removed in the future.
The font tag is obsolete.
Your LI tag is not closed properly, so your HTML is mal-formed.
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS
AndrewGSW is offline   Reply With Quote
Old 01-30-2013, 02:55 PM   PM User | #3
TFlan
New Coder

 
Join Date: Dec 2012
Location: USA
Posts: 82
Thanks: 3
Thanked 17 Times in 17 Posts
TFlan is an unknown quantity at this point
A better way:

PHP Code:
is_resource($q); 
$q being the results from the query
TFlan is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:27 AM.


Advertisement
Log in to turn off these ads.