lilgezuz Posted March 31, 2012 Share Posted March 31, 2012 I need to check my database to see if a user has earned a trophy. I have a table that holds the user id, game id, trophy id, and date earned. When I go to run my cron job It pulls data that may already be in my database so I need to check if a user has earned that trophy id for that game id. There is multiple game ids and each game id could have the same trophy id for example game 1 trophy 1 game 1 trophy 2 game 2 trophy 1 game 2 trophy 2 I tried to use mysql_num_rows but its not working for me Quote Link to comment Share on other sites More sharing options...
smerny Posted March 31, 2012 Share Posted March 31, 2012 show the query you were trying Quote Link to comment Share on other sites More sharing options...
lilgezuz Posted March 31, 2012 Author Share Posted March 31, 2012 show the query you were trying I deleted it already from my file but it was something like this $sql = mysql_query("SELECT gameid FROM earned WHERE userid='username' and tid='trophyid'"); if(mysql_num_rows($sql) >= 1){ ; ?> Quote Link to comment Share on other sites More sharing options...
smerny Posted April 1, 2012 Share Posted April 1, 2012 well i assume you had vars in for the username and trophyid... and actually, hope you are using a userid rather than a username. mysql_num_rows works... as long as it is used right. we can't help you without knowing what "not working" means and what the query is when it is not working. Quote Link to comment Share on other sites More sharing options...
lilgezuz Posted April 1, 2012 Author Share Posted April 1, 2012 well i assume you had vars in for the username and trophyid... and actually, hope you are using a userid rather than a username. mysql_num_rows works... as long as it is used right. we can't help you without knowing what "not working" means and what the query is when it is not working. the username is a id the tid and gameid are numbers. not working means that its not returning and results when it should be. I posted the query in my above post Quote Link to comment Share on other sites More sharing options...
smerny Posted April 1, 2012 Share Posted April 1, 2012 well then you have the problems i mentioned in my last post.. if that is the query you are using (as you say it is).. the only way you're going to have any result is if you have a "username" as a value in the "userid" field, and "trophyid" as a value in the "trophyid" field... which doesn't make any sense Quote Link to comment Share on other sites More sharing options...
fenway Posted April 1, 2012 Share Posted April 1, 2012 This is a basic php question -- you're not using variables. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.