MySQL/PHP更新查询错误 [英] MySQL/PHP update query error

查看:80
本文介绍了MySQL/PHP更新查询错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行一个查询,以从PHP更新表中的一小部分项目". 使用"Sequel Pro"运行代码可以完美地执行代码,而使用mysql("query here")在PHP上运行代码即可;失败了.

I'm running a query to update a small group of 'items' in a table, from PHP. Running the code with "Sequel Pro" executes it perfectly, while running it on PHP using mysql("query here"); fails miserably.

查询有问题吗?

UPDATE `service_joblocation` 
   SET  `in_use` =  '1', 
        `in_use_since` =  '1283488686', 
        `in_use_currentcount` =  `in_use_currentcount`+1, 
        `in_use_historicalcount`= `in_use_historicalcount`+1 
  WHERE `id` = 5 
  LIMIT 1;

UPDATE `service_joblocation` 
   SET `in_use` =  '1', 
       `in_use_since` =  '1283488686', 
       `in_use_currentcount` = `in_use_currentcount`+1, 
       `in_use_historicalcount` = `in_use_historicalcount`+1 
 WHERE `id`=16 
  LIMIT 1;

UPDATE `service_joblocation` 
   SET  `in_use` =  '1', 
        `in_use_since` = '1283488686', 
        `in_use_currentcount` = `in_use_currentcount`+1, 
        `in_use_historicalcount` = `in_use_historicalcount`+1 
  WHERE `id`=18 
   LIMIT 1;

UPDATE `service_items` SET  `checkin_user`='9', `checkin_date`='1283488686', `location`='5' WHERE `id`=576;
UPDATE `service_items` SET  `checkin_user`='9', `checkin_date`='1283488686', `location`='16' WHERE `id`=577;
UPDATE `service_items` SET  `checkin_user`='9', `checkin_date`='1283488686', `location`='18' WHERE `id`=578;
UPDATE `service_jobs` SET `checkin_date`='1283488686', `checkin_user`='9',`checkin_department`='1',`checkin_client_person`='0', `items_x`=`items_x`+1 WHERE `id`='518' LIMIT 1;
UPDATE `service_jobs` SET `checkin_date`='1283488686', `checkin_user`='9',`checkin_department`='1',`checkin_client_person`='0', `items_x`=`items_x`+1 WHERE `id`='518' LIMIT 1;
UPDATE `service_jobs` SET `checkin_date`='1283488686', `checkin_user`='9',`checkin_department`='1',`checkin_client_person`='0', `items_x`=`items_x`+1 WHERE `id`='518' LIMIT 1;

这是输出消息...

您的SQL语法有错误; 检查对应的手册 您的MySQL服务器版本 在'UPDATE附近使用正确的语法 service_joblocation设置in_use = '1',in_use_since ='1283488686'在 第2行

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 'UPDATE service_joblocation SET in_use = '1', in_use_since = '1283488686' at line 2

推荐答案

您只能将一条语句传递给mysql_query().

You can only pass a single statement to mysql_query().

还有其他功能/方法,例如 mysqli :: multi_query(),但不适用于旧版mysql扩展.

There are other functions/methods like e.g. mysqli::multi_query() but not for the old mysql extension.

这篇关于MySQL/PHP更新查询错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆