subash85 Posted December 20, 2009 Share Posted December 20, 2009 <?php $i = 0; $query1="SELECT * FROM `products` WHERE `division`='$f_usr_div' ORDER BY `pname` UNION SELECT `stock_close` FROM `stockiest_entry` WHERE `user_id`='$user_id' AND `stockiest_id`='$stckst_id' AND `month`='$f_month' AND `user_div`='$title_div' AND `fiscal_year`='$st_year'"; $result1=mysql_query($query1); $i=0; while($a_row=mysql_fetch_array($result1)) // line 89 { global $i; $i++; $db_id=$a_row['id']; $db_pname=$a_row['pname']; $db_pcode=$a_row['pcode']; $db_packing=$a_row['packing']; $db_type=$a_row['ptype']; $db_unit=$a_row['unit']; $db_stock_close=$a_row['stock_close']; print "$db_id, $db_pname, $db_pcode , $db_packing, $db_type, $db_unit, $db_stock_close"; i got error. Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /domains/55373/web/ipharma/form_header_final.php on line 89 Quote Link to comment https://forums.phpfreaks.com/topic/185791-mysql-union-warning-mysql_fetch_array/ Share on other sites More sharing options...
Buddski Posted December 20, 2009 Share Posted December 20, 2009 It means your query has failed to execute.. Use mysql_error() to find out the error Quote Link to comment https://forums.phpfreaks.com/topic/185791-mysql-union-warning-mysql_fetch_array/#findComment-981036 Share on other sites More sharing options...
subash85 Posted December 21, 2009 Author Share Posted December 21, 2009 <?php $i = 0; $query1="SELECT * FROM `products` WHERE `division`='$f_usr_div' ORDER BY `pname` UNION SELECT `stock_close` FROM `stockiest_entry` WHERE `user_id`='$user_id' AND `stockiest_id`='$stckst_id' AND `month`='$f_month' AND `user_div`='$title_div' AND `fiscal_year`='$st_year'"; $result1=mysql_query($query1); $i=0; while($a_row=mysql_fetch_array($result1)) // line 89 { global $i; $i++; $db_id=$a_row['id']; $db_pname=$a_row['pname']; $db_pcode=$a_row['pcode']; $db_packing=$a_row['packing']; $db_type=$a_row['ptype']; $db_unit=$a_row['unit']; $db_stock_close=$a_row['stock_close']; print "$db_id, $db_pname, $db_pcode , $db_packing, $db_type, $db_unit, $db_stock_close"; i got error. Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /domains/55373/web/ipharma/form_header_final.php on line 89 Execute MySql Error: Incorrect usage of UNION and ORDER BY what is wrong with my codin.. please any one help me out..! Quote Link to comment https://forums.phpfreaks.com/topic/185791-mysql-union-warning-mysql_fetch_array/#findComment-981425 Share on other sites More sharing options...
fenway Posted December 21, 2009 Share Posted December 21, 2009 Wrap your queries in parens. Quote Link to comment https://forums.phpfreaks.com/topic/185791-mysql-union-warning-mysql_fetch_array/#findComment-981694 Share on other sites More sharing options...
subash85 Posted December 23, 2009 Author Share Posted December 23, 2009 how to do that i didnt get ya.... em juz newbie to php so need some example helpps.. Quote Link to comment https://forums.phpfreaks.com/topic/185791-mysql-union-warning-mysql_fetch_array/#findComment-982820 Share on other sites More sharing options...
subash85 Posted December 23, 2009 Author Share Posted December 23, 2009 please anyone can help me to solve my problem... thank you... i will so greatful to you all... and the phpfreaks.com family... Quote Link to comment https://forums.phpfreaks.com/topic/185791-mysql-union-warning-mysql_fetch_array/#findComment-982829 Share on other sites More sharing options...
roopurt18 Posted December 23, 2009 Share Posted December 23, 2009 From my experience, you can not order the individual statements that constitute the UNION. select * from table1 order by col1 <-- BAD (and pointless anyways) union select * from table2 order by col1 <-- Applies to entire result set, meaning all statements in the union Someone correct me if I'm wrong please. Quote Link to comment https://forums.phpfreaks.com/topic/185791-mysql-union-warning-mysql_fetch_array/#findComment-982830 Share on other sites More sharing options...
fenway Posted December 27, 2009 Share Posted December 27, 2009 Write them as though they were sub-selects. Quote Link to comment https://forums.phpfreaks.com/topic/185791-mysql-union-warning-mysql_fetch_array/#findComment-984570 Share on other sites More sharing options...
subash85 Posted February 24, 2010 Author Share Posted February 24, 2010 mysql_error(Resource id #10) Quote Link to comment https://forums.phpfreaks.com/topic/185791-mysql-union-warning-mysql_fetch_array/#findComment-1017325 Share on other sites More sharing options...
fenway Posted February 24, 2010 Share Posted February 24, 2010 Great... what error, what query? Quote Link to comment https://forums.phpfreaks.com/topic/185791-mysql-union-warning-mysql_fetch_array/#findComment-1017654 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.