• 0

PHP query help


Question

Any idea why the following code displays this error? I am quite new to php and I'm struggling to see the error.


$stmt = $db->query('SELECT ti.playerid, ti.buydate, pl.playerid, pl.firstname, pl.lastname, pl.photo FROM transfersin as ti, players as pl WHERE ti.playerid = pl.playerid AND DATE_FORMAT(`ti.buydate`,\'%d.%m\') = DATE_FORMAT(NOW(),\'%d.%m\') ORDER BY ti.buydate ASC ');
[/CODE]

[b]Fatal error[/b][color=#000000]: Uncaught exception 'PDOException' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'ti.buydate' in 'where clause'' in /home/*/public_html/stats/onthisday.php:182 Stack trace: #0[/color]

Basically what I'm trying to do is show the results that happened on todays date, over the past 100 years. This actually worked until I moved some info into a new 'transfersin' column, then tried to alter the query but can't get it working.

Link to comment
https://www.neowin.net/forum/topic/1134194-php-query-help/
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Are you sure you have the column name exactly the same in the table?

You could also try removing the ticks around ti.buydate in the WHERE clause.

It's kind of hard to tell without the db schema.

  • 0

Basically it's not a PHP error, it's a MySQL (or other database system) error, you've removed or moved ti.buydate from the table you're trying to reference.

FROM transfersin as ti, players as pl

So you need to add and update that to include where buydate is or move it back to the transfersin table.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • War was livestreamed. Also, learn the meaning of the word "genocide". Populations do not GROW during a genocide. Zionist is not a bad word - it's the belief that Israel should exist. The cat out of the bag is your racist anitsemitism and posting of blood libels, unproven or out of context. Even BBC reported a kid supposedly being killed was a staged photo op, and AP just posted how Hamas is murdering their own people at Shifa Hospital, executing them in cold blood. You would rather lie down with murderers than think any different.
    • Neowin shudders at the many, many posts from users that block their ads
    • I'm from Australia. This posts reeks of a Nigerian scammer.
    • It's funny that iPhone users think they are getting feature, where in fact they are getting cosmetics that just do iteration circles of "improvement" of the said cosmetics. Apple just doesn't know what to do with this product anymore. There is no innovation on this areas anymore.
    • You can disable the bloat on every browser. That's not the point. I will never use a browser of a shady company. I don't trust them at all. I can still find adblocking solutions than having to rely on a browser from a shady company. Every year they try something shady lol 2016: Brave Ad Replacement https://archive.is/W0k4j#selection-203.7-203.28 2016: pay-to-win Wikipedia clone into the default search engine list https://github.com/brave/browser-laptop/issues/5475 2018: Tom Scott and other creators noticed Brave was soliciting donations in their names without their knowledge or consent. https://www.reddit.com/r/brave...aims_that_brave_is_falsely/ 2020: Brave got caught injecting URLs with affiliate codes https://www.theverge.com/2020/...-crypto-privacy-ceo-apology 2021: Brave's TOR window was found leaking DNS queries https://www.zdnet.com/article/...n-addresses-in-dns-traffic/ 2022: Brave floated the idea of further discouraging users from disabling sponsored messages. https://github.com/brave/brave-browser/issues/22066 2023: Brave got caught installing a paid VPN service on users' computers without their consent. https://www.xda-developers.com...owser-installs-vpn-windows/ 2023: Brave got caught scraping and reselling people's data with their custom web crawler, which was designed specifically not to announce itself to website owners. https://stackdiary.com/brave-s...ghted-data-for-ai-training/ 2024: Brave gave up on providing advanced fingerprint protection, citing flawed statistics https://www.bleepingcomputer.c...tion-as-it-breaks-websites/ 2025: Brave staff publish an article endorsing PrivacyTests and say they "work with legitimate testing sites" like them. This article fails to disclose PrivacyTests is run by a Brave Senior Architect! https://brave.com/blog/adblock...esting-websites-harm-users/
  • Recent Achievements

    • One Year In
      Primer1st earned a badge
      One Year In
    • Experienced
      JayZJay went up a rank
      Experienced
    • Reacting Well
      Sir_Timbit earned a badge
      Reacting Well
    • Week One Done
      rubentuben8 earned a badge
      Week One Done
    • Week One Done
      ARaclen earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      511
    2. 2
      PsYcHoKiLLa
      229
    3. 3
      Edouard
      135
    4. 4
      ATLien_0
      87
    5. 5
      Steven P.
      80
  • Tell a friend

    Love Neowin? Tell a friend!