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); Link to comment https://forums.phpfreaks.com/topic/293042-trying-to-merge-2-queries-using-union/ Share on other sites More sharing options...
Barand Posted December 11, 2014 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; 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. 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
Archived
This topic is now archived and is closed to further replies.