Jump to content

Recommended Posts

Im trying to check if a user exist in database table only if another check =YES:

 

$sql="SELECT * FROM my_members WHERE my_private=$my_private AND my_id=$my_id";

 

$my_private should = 'Yes' or 'No'.

 

If 'Yes', i need to run another check....

 

$sql="SELECT * FROM my_favorites WHERE my_id=$my_id AND my_uid=$sessionuser";

 

This check should check to see if $sessionuser exists in my_favorites..

 

How can i make the first one call the second only if $my_private=Yes? Or is this code even correct?

Link to comment
https://forums.phpfreaks.com/topic/69846-check-mysql-database-for-user/
Share on other sites

How about 1 query instead?

 

$sql="
  SELECT mf.*
  FROM my_favorites mf
  RIGHT JOIN my_members mm
      ON mf.my_id = mm.my_id
  WHERE mf.my_id=$my_id
      AND mf.my_uid=$sessionuser
      mm.my_private=$my_private";

Both did not work for me in that page, but did work in others. What i cant get it to recognize both variables at the same time.

 

If($my_private=='Yes' && !$sessionuser) {

      header("Location: gen_confirm.php?errmsg=".urlencode("This user has profile set to private. Only friends can view this page.<BR><a href=".addme_request.php.">Click here to request to be added.</a>"));

die();

}

 

I can get it to check the my_private, but not the my_ud from database.  ???

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.