×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Trying to find is a null is True False

Trying to find is a null is True False

Trying to find is a null is True False

(OP)
I am trying to check to confirm that both memberid and recipeid is not null. That way if both have value it will allow the member to ad the ripe to there list if both have a value it will tell them the recipe they are adding is already in there list. Working on this for a while need help and trying to transition from asp classic to php winky smile.

$check_fav = mysql_query("SELECT memberid, recipeid FROM favorites WHERE (memberid = '".$memberid."' AND recipeid = '".$id."')");

If ($check_fav == TRUE){.......

RE: Trying to find is a null is True False

Your query already does the checking for the existence of a recipe, all you need to do is verify whether your query returned a row or not. Checking for true or false will only tell you the query succeeded, but it can succeed even if it did not bring anything back. 0 results would mean the recipe does not exist. At least one result means it already does.

Try:

CODE

$rows = if(mysql_num_rows($check_fav) > 0)
{
//recipe exists
} else {
//recipe does not exist
}

PHP Online Manual: mysql_num_rows()

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech

RE: Trying to find is a null is True False

The mysql_* functions were deprecated some years ago and don't even exist in the latest version of PHP. It is better to use mysqli_* or PDO.

I'm not a number, I'm a free man

RE: Trying to find is a null is True False

Just as a minor point of programming semantics;

Quote:

Trying to find is a null is True False

A NULL is neither 'true' or 'false', it is simply NULL (equating to Nothing)

So your question should be something like "Testing for a NULL value"

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close