[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
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
Medium Priority
?
268 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 82

Accepted Solution

by:
hielo earned 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

649 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