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 Link to comment https://forums.phpfreaks.com/topic/273759-in-and-and-in-asingle-sql-query/ 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? Link to comment https://forums.phpfreaks.com/topic/273759-in-and-and-in-asingle-sql-query/#findComment-1408837 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 Link to comment https://forums.phpfreaks.com/topic/273759-in-and-and-in-asingle-sql-query/#findComment-1408840 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. Link to comment https://forums.phpfreaks.com/topic/273759-in-and-and-in-asingle-sql-query/#findComment-1408843 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 Link to comment https://forums.phpfreaks.com/topic/273759-in-and-and-in-asingle-sql-query/#findComment-1408881 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.