PHP多个MYSQL命令在一个mysql_query()查询 [英] PHP multiple MYSQL commands in one mysql_query() query

查看:202
本文介绍了PHP多个MYSQL命令在一个mysql_query()查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用一个mysql_query函数发出多个mysql命令。
这是我的代码:

  $ query。=INSERT INTO`users'VALUES(1,'stack' ,'溢出');; 
$ query。=INSERT INTO`posts` VALUES('other','stack','overflow');;
mysql_query($ query);

如果我这样做,我得到一个警告,我的语法将不正确。



这里的错误在哪里?


如果我回显输出, div class =h2_lin>解决方案

我认为你需要这个? http://us2.php.net/manual/en/mysqli.multi -query.php


I want to issue multiple mysql commands with one mysql_query function. This is my code:

$query .= "INSERT INTO `users` VALUES(1,'stack','overflow');";
$query .= "INSERT INTO `posts` VALUES('other','stack','overflow');";
mysql_query($query);

If I do that I get a warning that my syntax would be incorrect. If I echo the output, copy it and execute it in phpMyAdmin it works.

Where is the error there?

解决方案

I think you need this?? http://us2.php.net/manual/en/mysqli.multi-query.php

这篇关于PHP多个MYSQL命令在一个mysql_query()查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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