johnmartel johnmartel - 1 year ago 90
MySQL Question

getting error from mysqli_fetch_array

My query line is:

PL.*, DE.*,
( DE.power + DE.stamina + DE.violence + DE.speed + DE.shooting + DE.scoring + DE.pass + DE.ball_control + DE.talent ) AS TPOWER,
strftime('%Y-%d-%m', DE.age, 'unixepoch') AS age
FROM `transfers` TR JOIN `players` PL ON
JOIN `playerdetails` DE ON TR.player_id=DE.player_id
WHERE PL.position = 'MD' AND ( age >= '20' AND age <= '24' )
AND PL.firstname = 'a' AND PL.lastname = 'b' AND TPOWER >= '1'
AND TPOWER <= '5' AND TR.price >= '20' AND TR.price <= '50'

What's wrong with this query?

An error occurred:

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in E:\EasyPHP-Devserver-16.1\eds-www\classes\DB.php on line 15

Answer Source

MySQL doesn't have a function called strftime(). You might want date_format() instead:

SELECT . . .
       date_format(de.age, '%Y-%d-%m') AS age 

However, that seems like a strange way to express the age (which is usually an integer, number, or interval).

Your query could have other errors as well. You should check the error messages that are returned.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download