Jump to content


Photo

PHP query not working properly

php mysql

Best Answer MstrGmrDLP, 09 April 2014 - 08:38 PM

I had already fixed this by the time you posted that. Thanks for trying to help. Sorry for wasting your time.

Go to the full post


  • Please log in to reply
2 replies to this topic

#1 MstrGmrDLP

MstrGmrDLP

    Member

  • Members
  • PipPip
  • 10 posts

Posted 06 April 2014 - 06:17 PM

So my code
 

<? $reqcount = mysql_query("SELECT * FROM friend_reqs WHERE user_to={$_SESSION['user']['user_id']} AND user_from!={$_SESSION['user']['user_id']}"); $reqs = sizeof($reqcount);?>

 

 

 

 

 

I have 3 requests for the user and it only shows 1. What is the problem?



#2 DavidAM

DavidAM

    Advanced Member

  • Gurus
  • 1,976 posts
  • LocationSpring, TX USA

Posted 06 April 2014 - 07:28 PM

mysql_query returns a resource, NOT the query results. You need to fetch the data.

Other comments:
1) The mysql library is deprecated, use mysqli (mysqli)
2) Don't use short tags "<?", use full tags: "<?php"
3) Use SELECT COUNT(*) if you want a count, don't return all of the data if you don't need it
-- I haven't lost my mind, it's backed up on tape ... somewhere!

#3 MstrGmrDLP

MstrGmrDLP

    Member

  • Members
  • PipPip
  • 10 posts

Posted 09 April 2014 - 08:38 PM   Best Answer

I had already fixed this by the time you posted that. Thanks for trying to help. Sorry for wasting your time.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com