Jump to content

No array echo output - Please help


bambinou1980

Recommended Posts

Hello,

 

I am not understanding why, I do not get an array output there, is there a problem with my php code?

 

                    <?php                    $query = "SELECT                              o.orders_id,                            date_format(o.due_date, '%d/%m/%Y') as day,                            o.customer_paid,                            p.product_price,                            p.product_quantity,                            p.product_price * p.product_quantity AS totals,                            p.orders_orders_id                             FROM orders AS o                            LEFT JOIN products_ordered AS p                            ON o.orders_id = p.orders_orders_id                            WHERE YEAR(o.due_date) = YEAR(CURDATE()) AND MONTH(o.due_date) = MONTH(CURDATE())                            WHERE o.customer_paid = 'PAID'                            GROUP BY o.orders_id";                          if (mysqli_connect_errno())                        die('Could not connect: ' . mysql_error());                     $return_arr = array();                     if ($result = mysqli_query($connection, $query)) {                        while ($row = mysqli_fetch_assoc($result)) {                            $row_array['orders_id']     = $row['orders_id'];                            $row_array['product_price'] = $row['product_price'];                             array_push($return_arr, $row_array);                        }                    }                     mysqli_close($connection);                     echo json_encode($return_arr);                                        ?>

 
Thanks
Link to comment
Share on other sites

is there a problem with my php code?

 

 

rather than just asking someone else which keys to push to fix a problem, how about debugging the problem yourself? between the forums that i know you post on, you have several hundred posts. at this point, you should be able to isolate a problem with your code and queries to at least the pin down where the problem is at and by looking at where the problem is at, you may be able to solve it yourself.

 

is your query running or is it producing an error? do you have error checking and error handling logic in your code for the query?

 

is your query running, but not matching any rows? do you have any logic in your code to test for this condition and output an appropriate result for the case of no matching rows?

Link to comment
Share on other sites

I see a mysqli query call, a mysqli connect error check and a MySQL (no I) error code display. But I don't see how you made your db connection. Dare I ask if it was MySQL (no I)?

 

Are you doing error checking during your development as a good programmer usually (always?) does?

 

And of course the faulty query statement that Barand previously pointed out.

 

PS - you don't think that people who post across multiple forums aren't noticed by those who visit the boards regularly? On what planet do you live? If I were you I would be more concerned about the weakness in your debugging ability that was pointed out to you.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.