Query working in phpmyadmin but not in php script page

时间:2017-03-22 18:40:48

标签: php mysql mysqli phpmyadmin

I've been racking my brains for this all afternoon. Ive search various forums and web sites and nothing seems to be working right.

This is the SQL query that i got help with earlier from a member on Stackoverflow and works perfectly in phpmyadmin SQL query window

UPDATE members SET  `status` = IF( (
SELECT monday_ashore
FROM system
WHERE id =  '1'
) =  'Yes',  'ASHORE',  `status` );

and this is the code that i have in the php script:

//Monday Force All Ashore Cron Page <?php
include ("../config/db_connect.php");
$sql = ("UPDATE members SET  `status` = IF( (
SELECT monday_ashore
FROM system
WHERE id =  '1'
) =  'Yes',  'ASHORE',  `status` ");
?>

This script is set to be a CRON script. how do i get it to run by navigating to it through web site for testing and for it to actually work. What am i doing wrong or missing, any help would be greatly appreciated.

1 个答案:

答案 0 :(得分:0)

From what I can see it's in your 'include' statement. Since you are referencing it dynmaically with a '../' there is no guarantee cron will accept that (cron assumes you are starting from your home directory). change that to a fully qualified directory name and that should solve your problem, as mentioned above fix your missing ')'