hassank1 Posted March 28, 2008 Share Posted March 28, 2008 I've got an error executing this script !! I don't know what's wrong !! $StudyGroups=array( 'Arts & Design', 'Engineering', 'Education', 'Communication Arts', 'Computer', 'Business', 'Pharmacy', 'sciences', 'Lab Reports (Engineering)', 'Lab Reports (Sciences)' ); $GetStudyGroups_Query="select GroupID,GroupName from groups where GroupName IN $StudyGroups "; $StudyGroups_Result=mysql_query($GetStudyGroups_Query); echo mysql_num_rows($StudyGroups_Result);exit(); Quote Link to comment Share on other sites More sharing options...
dezkit Posted March 28, 2008 Share Posted March 28, 2008 <? $StudyGroups=array( 'Arts & Design', 'Engineering', 'Education', 'Communication Arts', 'Computer', 'Business', 'Pharmacy', 'sciences', 'Lab Reports (Engineering)', 'Lab Reports (Sciences)' ); $GetStudyGroups_Query="select GroupID,GroupName from groups where GroupName IN $StudyGroups "; $StudyGroups_Result=mysql_query($GetStudyGroups_Query); echo mysql_num_rows($StudyGroups_Result);exit(); ?> Quote Link to comment Share on other sites More sharing options...
hassank1 Posted March 28, 2008 Author Share Posted March 28, 2008 it is still the same !! Quote Link to comment Share on other sites More sharing options...
alecks Posted March 28, 2008 Share Posted March 28, 2008 what is the error, that you are getting... Quote Link to comment Share on other sites More sharing options...
Barand Posted March 28, 2008 Share Posted March 28, 2008 <?php $groupList = join ("','", $studyGroups); $GetStudyGroups_Query="select GroupID,GroupName from groups where GroupName IN ('$groupList'); "; Quote Link to comment Share on other sites More sharing options...
hassank1 Posted March 28, 2008 Author Share Posted March 28, 2008 <?php $groupList = join ("','", $studyGroups); $GetStudyGroups_Query="select GroupID,GroupName from groups where GroupName IN ('$groupList'); "; thanks it worked however,why my previous code didn't work ? and what the above code means (join() !! ) ? Quote Link to comment Share on other sites More sharing options...
Barand Posted March 28, 2008 Share Posted March 28, 2008 if you have $ar = array ('A'. 'B', 'C'); then join (',' , $ar) returns "A,B,C" (the array elements separated by a comma). For your query you needed .... IN ('A','B','C') , with quotes, so I joined the elements with "','" www.php.net/join Quote Link to comment Share on other sites More sharing options...
hassank1 Posted March 28, 2008 Author Share Posted March 28, 2008 ok thx . SOLVED Quote Link to comment Share on other sites More sharing options...
Barand Posted March 28, 2008 Share Posted March 28, 2008 however,why my previous code didn't work ? try doing it your way and echo $GetStudyGroups_Query; then echo my query. 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.