Select 从选择插入到

Select 从选择插入到,select,syntax-error,insert-into,Select,Syntax Error,Insert Into,我有一个小问题,我不能理解。 我希望查询结果写入现有表中 $ query = "SELECT * FROM actions WHERE 1 = 1";/ w_cliente $ = ""; if ($ customer! = "") {$ w_cliente = "AND customer LIKE '%". $ client. "%'";} w_cognome $ = ""; if ($ name! = "") {$ w_cognome = "AND name LIKE '%". $ n

我有一个小问题,我不能理解。 我希望查询结果写入现有表中

   $ query = "SELECT * FROM actions WHERE 1 = 1";/
w_cliente $ = "";
if ($ customer! = "") {$ w_cliente = "AND customer LIKE '%". $ client. "%'";}
w_cognome $ = "";
if ($ name! = "") {$ w_cognome = "AND name LIKE '%". $ name. "%'";}
w_nome $ = "";
if ($ name! = "") {$ w_nome = "AND name LIKE '%". $ name. "%'";}
$ query. = $ w_tipologia. $ w_cognome. $ w_nome. "ORDER BY id";
$ res = mysql_query ($ query) or die ('Error: Something went wrong');
$ exists = mysql_num_rows ($ res);
此查询可以“打印”查找表

$ query = "INSERT INTO time SELECT * FROM actions WHERE 1 = 1";/
w_cliente $ = "";
if ($ customer! = "") {$ w_cliente = "AND customer LIKE '%". $ client. "%'";}
w_cognome $ = "";
if ($ name! = "") {$ w_cognome = "AND name LIKE '%". $ name. "%'";}
w_nome $ = "";
if ($ name! = "") {$ w_nome = "AND name LIKE '%". $ name. "%'";}
$ query. = $ w_tipologia. $ w_cognome. $ w_nome. "ORDER BY id";
$ res = mysql_query ($ query) or die ('Error: Something went wrong');
$ exists = mysql_num_rows ($ res);
这样,我看不到任何打印内容,而是将数据正确写入表中。 如何在研究中显示视频并同时将数据输入新表?
谢谢。

问题是在连接条件时没有在条件之间留出空格。例如,如果设置了
$customer
,您将得到:

WHERE 1=1AND customer LIKE %$client%

要解决此问题,请在
之前和
ORDER BY
之前添加空格。

在PHP中,请不要在
$
之后添加空格。它可以工作,但没有人编写这样的代码。
$
被认为是变量名的一部分完全无效。您的代码应该出现解析错误,甚至没有运行。请发布运行的代码。将
die('Error:Something出错')
更改为
dir(mysql\u Error())
,以便您看到原因,并将错误消息添加到您的帖子中。