shmideo Posted December 11, 2014 Share Posted December 11, 2014 The queries merge ok and results are correct except I get a notice: "Notice: Use of undefined constant UNION - assumed 'UNION' in...." But is UNION a constant or is the context wrong? $query = $query1." ".UNION." ".$query2; $result = mysqli_query($dbcon, $query) or die('Error getting data'); $num_rows = mysqli_num_rows($result); Quote Link to comment https://forums.phpfreaks.com/topic/293042-trying-to-merge-2-queries-using-union/ Share on other sites More sharing options...
Solution Barand Posted December 11, 2014 Solution Share Posted December 11, 2014 Your syntax is wrong. UNION should be inside the quotes otherwise PHP assumes it is defined constant. When it then finds no definition then it assumes (correctly) that it meant to be a string value. $query = $query1 . " UNION " . $query2; Quote Link to comment https://forums.phpfreaks.com/topic/293042-trying-to-merge-2-queries-using-union/#findComment-1499341 Share on other sites More sharing options...
shmideo Posted December 11, 2014 Author Share Posted December 11, 2014 Thank you so much Barand. Quote Link to comment https://forums.phpfreaks.com/topic/293042-trying-to-merge-2-queries-using-union/#findComment-1499343 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.