Undefined index: message_total this error is occuring in php

$sql1="select a.message_total,b.message_sent from 
( SELECT 
batch_id, count(phone) message_total from to_numbers  group by batch_id
 ) a left outer join
  ( SELECT 
batch_id, count(phone) message_sent from message_sent  group by batch_id
   ) b
   on a.batch_id=b.batch_id 
   where a.batch_id=".$max_id."";

$out = '';  

      $result1 = mysqli_query($db, $sql1);
      
      while($row = mysqli_fetch_row($result1))  
      {  
         
        $out .='<table class="table table-bordered"><tr><td width="30%"><label>message_total</label></td><td width="70%">'.$row['message_total'].'</td></tr><tr><td width="30%"><label>message_sent</label></td><td width="70%">'.$row['message_sent'].'</td></tr></table>';  
      }  

Open in new window


the below error is coming

"
\nNotice: Undefined index: message_total in C:\\xampp\\htdocs\\whatsapp_message_sender\\importData.php on line 256
\n
\nNotice: Undefined index: message_sent in C:\\xampp\\htdocs\\whatsapp_message_sender\\importData.php on line 256
\n<table class="table table-bordered"><tr><td width="30%"><label>message_total</label></td><td width="70%"></td></tr><tr><td width="30%"><label>message_sent</label></td><td width="70%"></td></tr></table> success "

please let me know the solution
shruti Aweb developerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Vel EousResearch & Development ManagerCommented:
The error is telling you that the index 'message_total' within your $row assoc array does not exist.  Inspect the content of $row to determine what is actually defined.
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
If message_total can come back unset (NULL), then be sure to test for this condition first + then skip further processing if you have a row with a NULL message_total value.

Or you can just extend your SELECT to include tests to only return rows with message_total != 0 or != NULL, however you've designed your schema.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
Accepting two similar answers.

Posted has stopped posting.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.