wright67uk Posted January 28, 2013 Share Posted January 28, 2013 I'm trying to write a query where: I pull records for any user_id that's within $mystring, whilst linking the registration table and 18scorecard table by user_id. Im not sure the best way to do this. $mystring gets its value from an implode at the moment its 5,6,7 Heres what ive got so far... ("SELECT * FROM registration, 18scorecard WHERE registration.user_id IN ($mystring) AND 18scorecard.user_id = registration.user_id"); Is it possible to change this query, to get the result i'm looking for? At the moment im greeted with a mysql fetch array error Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted January 28, 2013 Share Posted January 28, 2013 What exactly did your use of mysql_error reporting state was the reason why the query is failing? Quote Link to comment Share on other sites More sharing options...
wright67uk Posted January 28, 2013 Author Share Posted January 28, 2013 Well I actually have a warning which reads: supplied argument is not a valid MySQL result resource Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted January 28, 2013 Share Posted January 28, 2013 That's a php error message. That's not what someone asked you. Quote Link to comment Share on other sites More sharing options...
wright67uk Posted January 29, 2013 Author Share Posted January 29, 2013 Yes your right. :-\ ... 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') AND 18scorecard.user_id = registration.user_id' at line 1 After using this, i realised that $mystring didn't echo as it should. I have now ensured that the variable carries a value, and now everything works fine. I will also ensure that I use error messages and version numbers if I ever need help again. Thankyou 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.