• 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

    • There is a lot of reasons not to use Edge but faster fixes and security updates is not one of them.
    • Can't reproduce. I installed Edge, went to neowin.net > accepted the cookie consent > used menu to go to forums, everything loads and I can browse around the forums. If you can't interact with the dialog on the forums for some reason, go to the main site and accept the cookie consent there? It is true that the site will not function properly until the cookie consent is accepted or rejected,. it's a legal requirement and I also know that certain VPN/ad blockers block it, which is a user related issue and not a neowin.net problem.   This is not our cookie consent dialog. Gotta love browser hijacking... /s Edit: this may be what Californians see, I will confirm with our consent provider.
    • Google Chrome 149.0.7827.115 (offline installer) by Razvan Serea The web browser is arguably the most important piece of software on your computer. You spend much of your time online inside a browser: when you search, chat, email, shop, bank, read the news, and watch videos online, you often do all this using a browser. Google Chrome is a browser that combines a minimal design with sophisticated technology to make the web faster, safer, and easier. Use one box for everything--type in the address bar and get suggestions for both search and Web pages. Thumbnails of your top sites let you access your favorite pages instantly with lightning speed from any new tab. Desktop shortcuts allow you to launch your favorite Web apps straight from your desktop. Chrome has many useful features built in, including automatic full-page translation and access to thousands of apps, extensions, and themes from the Chrome Web Store. Google Chrome is one of the best solutions for Internet browsing giving you high level of security, speed and great features. Important to know! The offline installer links do not include the automatic update feature. Download web installer: Google Chrome Web 32-bit | Google Chrome 64-bit | Freeware Download: Google Chrome Offline Installer 64-bit | Direct Link | 131.0 MB Download: Google Chrome Offline Installer 32-bit | Direct Link | 119.0 MB Download page: Google Chrome Portable Download: Chrome ARM64 | Direct Link View: Chrome Website | Release Notes Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • Oh, it's happening on more than one dialog? This is the dialog that I'm unable to interact with.
    • WSCC - Windows System Control Center 10.0.3.8 by Razvan Serea Windows System Control Center is a free, portable program that allows you to install, update, execute and organize the utilities from various system utility suites. WSCC can install and update the supported utilities automatically. Alternatively, WSCC can use the http protocol to download and run the programs. WSCC is portable, installation is not required. Extract the content of the downloaded zip archive to any directory on your computer. Free for personal use. The setup packages and updates are downloaded directly from their author's website! This edition of WSCC supports the following utility suites: Windows Sysinternals Suite (including support for "Sysinternals Live" service) NirSoft Utilities Mitec and more... WSCC - Windows System Control Center 10.0.3.8 changelog: [NEW] update progress is now visible on the Windows taskbar [FIXED] fixed an issue with the Update dialog [FIXED] minor fixes Download: WSCC (64-bit) | 5.4 MB (Free for personal use) Download: WSCC (32-bit) | 6.3 MB View: WSCC Homepage | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
  • Recent Achievements

    • One Month Later
      Clizby earned a badge
      One Month Later
    • One Month Later
      Timaximus earned a badge
      One Month Later
    • Week One Done
      Timaximus earned a badge
      Week One Done
    • Rookie
      FBSPL went up a rank
      Rookie
    • First Post
      davidbazooked earned a badge
      First Post
  • Popular Contributors

    1. 1
      +primortal
      492
    2. 2
      PsYcHoKiLLa
      170
    3. 3
      +Edouard
      164
    4. 4
      Steven P.
      85
    5. 5
      ATLien_0
      77
  • Tell a friend

    Love Neowin? Tell a friend!