MySQL语法错误;适用于PHPMyAdmin但不适用于PHP代码

时间:2015-09-10 05:20:29

标签: php mysql

在我的PHP脚本中运行它时,我无法弄清楚为什么它不起作用。它使用PHPMyAdmin ...

工作正常
You have an error in your SQL syntax; check the manual that corresponds to your
MySQL server version for the right syntax to use near 
'INSERT INTO `gamecoms_website`.`DailyUsers` (UserCount, TheDate, TheTime, TheDat' at line 2

以下是代码:

SET SESSION time_zone = '+00:00';
    INSERT INTO `gamecoms_site`.`DailyUsers` (UserCount, TheDate, TheTime, TheDateTime) VALUES ('$online', CURDATE(), CURTIME(), NOW());
    DELETE FROM `gamecoms_site`.`DailyUsers` WHERE TheDateTime < ADDTIME(NOW(), '-24:00:00');
    SELECT `UserCount`, `TheDate` , `TheTime`, `TheDateTime` INTO @UserCount ,@TheDate ,@TheTime ,@TheDateTime FROM `gamecoms_website`.`DailyUsers` ORDER BY UserCount DESC LIMIT 1;
    UPDATE  `gamecoms_site`.`AllTimeUsers`
        SET
            TheDate = CASE WHEN UserCount < @UserCount THEN @TheDate END,
            TheTime = CASE WHEN UserCount < @UserCount THEN @TheTime END,
            TheDateTime = CASE WHEN UserCount < @UserCount THEN @TheDateTime END,
            UserCount = CASE WHEN UserCount < @UserCount THEN @UserCount END;

1 个答案:

答案 0 :(得分:0)

您应该使用http://php.net/manual/ru/mysqli.multi-query.php

或单独查询