Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource

I constructed a query in phpmyadmin which was successful. I then moved it into a php script, and am getting the error:

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource (line 135)

$query="SELECT timestamp as timestamp FROM `stats` WHERE `pilot_callsign` = $player_id and `action` = 'kill' and `pilot_team` != `victim_team` order by 'timestamp' LIMIT 0 , 1;";
$result=mysql_query($query);
line 135: $row=mysql_fetch_assoc($result);
$quote=$row['timestamp'];
echo $quote;

Can anybody explain what is wrong here?
Dodger42Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
$query="SELECT `timestamp` as timestamp FROM `stats` WHERE `pilot_callsign` = $player_id and `action` = 'kill' and `pilot_team` != `victim_team` order by `timestamp` LIMIT 0 , 1;";

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Dan_82Commented:
Maybe off the mark but i don't think you need to have timestamp as timestamp because 'AS' is used far alias's, which i don't think you need here.  Might not solve the problem but may make the query simpler.
See http://dev.mysql.com/doc/refman/5.0/en/select.html for more info on AS

Also may help to start with a query like
SELECT `timestamp` as timestamp FROM `stats` WHERE `pilot_callsign` = '5'
then if it works replace the 5 with the variable and then add the other conditions 1 by 1
kamermansCommented:
Also, get rid of the semicolon in the query - you don't need these PHP:

$query="SELECT `timestamp` as timestamp FROM `stats` WHERE `pilot_callsign` = $player_id and `action` = 'kill' and `pilot_team` != `victim_team` order by `timestamp` LIMIT 0 , 1";

Then add an error handler to your mysql_query() call:

$result=mysql_query($query) or die("Could not query database: ".mysql_error());
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.