where i went wrong please help urgent

<?php include 'dbConfig.php';
        <div class="table" style="display: <?php echo isset($_POST['find']) ? "none" : "block" ?>">

        <table class="table table-bordered table-striped msg-reports-table" id="table" display="">
      //$res=mysqli_query($db,"Select f.fname,f.sname,f.mail,f.num,f.gen,s.tadd,s.padd,s.amail,s.anum,s.status from first f,second s ");
//echo $$sql1="select f.fname,f.sname,f.mail,f.num,f.gen,s.tadd,s.padd,s.amail,s.anum,s.status from 
// ( SELECT 
// * first from to_numbers
//  ) f left outer join
//   ( SELECT 
// *  from second  
//    ) s";res;

$res=   mysqli_query($db,"Select * from first UNION select * from second ");
        echo "<tr><td colspan='5'></td></tr>";
             while($row = mysqli_fetch_assoc($res))  
                               echo '  

Open in new window

 Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\third.php on line 22
shruti aAsked:
Who is Participating?
Julian HansenConnect With a Mentor Commented:
[Please use code tags - makes it easier to read - for instance line 22 has meaning - added them for you]

The error is saying that the mysqli_query failed.

Add this after line
$res=   mysqli_query($db,"Select * from first UNION select * from second ");
if (!$res) {
    echo "Query failed with error : " . mysqli_error($db);
else {
   // rest of your code here

Open in new window

EDIT: Fixed typo ($res) - thanks to Jim Riddles for pointing it out
Jim RiddlesPrepress/OMS SpecialistCommented:
Julian, you have a typo on line 2...you're missing the "$" in front of res.
Jim RiddlesPrepress/OMS SpecialistCommented:
With no further input from the author, Julian's solution answers the question.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.