Solved

What value does $query = mysql_query("select * from member where loginID like '$loginID'") return if there is no field with loginID = $loginID

Posted on 2008-06-21
4
220 Views
Last Modified: 2008-06-22
I have the following code...
$query = mysql_query("select * from member where loginID like '$loginID'");

I have an if statement that follows as thus...
if(!empty($query)){
//code
}

that if statement, though, won't execute if there is a value in $query
0
Comment
Question by:jabrthel
  • 2
  • 2
4 Comments
 
LVL 82

Accepted Solution

by:
hielo earned 500 total points
ID: 21839741
it returns a resource which has zero records. So if you are trying to find out how many records were returned you need:
$query = mysql_query("select * from member where loginID like '$loginID'");
if( 0==mysql_num_rows($query) )
{
  echo "No records found";
}
0
 

Author Comment

by:jabrthel
ID: 21839807
That worked, I just needed to change == to !=
0
 

Author Comment

by:jabrthel
ID: 21839809
thanks
0
 
LVL 82

Expert Comment

by:hielo
ID: 21840973
You are welcome!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article discusses four methods for overlaying images in a container on a web page
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now