Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
    ( ! ) SCREAM: Error suppression ignored for
    ( ! ) Notice: Undefined index: q_sold in C:\wamp\www\aaa\mup.php on line 93
    Call Stack
    #   Time    Memory  Function    Location
    1   0.0039  144192  {main}( )   ..\mup.php:0

I got Undefined Index for this code:

<table align="center" border="2">
   <tr>
    <td align="center"> <font color="">  Quantity Sold:</td>
    <td align="center"> <font color="">  Month:</td>
   </tr>

<?php
include 'connect.php';


$bogart=mysqli_query($con," SELECT  `month`, sum(q_sold) as sold_sum
FROM  `samsung_store` group by `month` order by sold_sum desc
LIMIT 1 ") or die (mysql_error());

$count=mysqli_num_rows($bogart);

while($baragan=mysqli_fetch_array($bogart)){

if($count % 2 == 0){
$color="#EDEDED";
$count--;
}
else{
$color="white";
$count--;
}
?>

 <tr bgcolor="<?php echo $color?>">
      <td> <?php echo $baragan['q_sold']?></td>
      <td> <?php echo $baragan['month'] ?></td>
    </tr>

<?php
}
?>

</form>
</table>

I just need to remove the error. which I don't know How I tried to put "@" sign at the beginning of the: but didn't work

$bogart=msqli_query

Sorry I'm a beginner please bare. Thanks.

share|improve this question
sum(q_sold) as sold_sum means that it should be accessed as $baragan['sold_sum'] - you are naming it differently within the query – FDL 4 hours ago
Oh thanks. Sorry foprgot to look at that. I'm too fool. Haha sorry fot bothering you guys. Thanks – user2497414 4 hours ago

1 Answer

up vote 5 down vote accepted
<td> <?php echo $baragan['q_sold']?></td>

Why do you access the index q_sold, when you are selecting in your query the alias named sold_sum?

Change it to:

<td> <?php echo $baragan['sold_sum']?></td>

Hint: Use print_r($baragan); to see what is going wrong here.

share|improve this answer
Thanks :) sorry for bothering I forgot to look at that. Too fool for that. Sorry and thank you so much. – user2497414 4 hours ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.