Sign in to follow this  
Followers 0

PHP query help

3 posts in this topic

Posted

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 ');

Fatal error: 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

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.

Share this post


Link to post
Share on other sites

Posted

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.

1 person likes this

Share this post


Link to post
Share on other sites

Posted

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.