Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8788305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:07:07+00:00 2026-06-13T22:07:07+00:00

I’m running a query on our customer order database to see the sales from

  • 0

I’m running a query on our customer order database to see the sales from the last week. The query looks like this:

select
distinct day(from_unixtime(customerorder.datetime)) as day,
count(distinct customerorder.customerorderid) as count_totalorders,
count(distinct customerorderpos.itemid) as count_differentitems,
sum(customerorderpos.quantity_ordered) as quantity_ordered,
sum(customerorderpos.itemsubtotal) as item_subtotal,
sum(customerorderpos.pricechangetotal) as item_pricechangetotal,
sum(customerorderpos.itemtotal) as item_total,
sum(customerorderpos.purchase_price * customerorderpos.quantity_ordered) as item_purchasepricetotal,
sum(distinct cart_discounttotal) as total_discount,
sum(customerorderpos.itemtotal - (customerorderpos.purchase_price * customerorderpos.quantity_ordered) - (select distinct cart_discounttotal)) as item_earningstotal,
sum(distinct cart_total_shipping) as total_shipping,
sum(distinct cart_total_tax) as total_tax,
sum(distinct cart_total_complete) as total_complete
from customerorder
inner join customerorderpos on customerorder.customerorderid = customerorderpos.customerorderid
where
customerorder.datetime >= 1351494000 and
customerorder.status_cancelled = "0"
group by day(from_unixtime(customerorder.datetime))
order by customerorder.datetime

When I enter the query in PhpMyAdmin in works fine and shows the last 7 days orders. But when we run it in our own software it gives an error.

$result = $db->query($query);
while ($row = $result->fetch_assoc()){

This shows: “Fatal error: Call to a member function fetch_assoc() on a non-object”

But…. if I take out “where customerorder.datetime >= 1351494000” from the query it works fine.
In other words the query works perfectly until I want to limit it to a specific time. Customerorder.datetime is an int(11) column with a timestamp.

Any ideas what the problem could be?

Thanks for your help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T22:07:08+00:00Added an answer on June 13, 2026 at 10:07 pm

    Thanks for your help. I found the problem though, it was (of course) my own mistake!
    The actual SQL syntax was fine, I just had an error in our own software (the $query was running though a clean-up function that replaced the “>=” characters, making the query invalid).

    Sorry for wasting your time 🙁

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
Let's say I'm outputting a post title and in our database, it's Hello Y’all
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am currently running into a problem where an element is coming back from
Does anyone know how can I replace this 2 symbol below from the string
I have a view passing on information from a database: def serve_article(request, id): served_article
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.