PHP数据库插入无法按计划工作 [英] php database insert not working according to plan

查看:73
本文介绍了PHP数据库插入无法按计划工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此代码引发了一个错误,我尝试进行故障排除,但是我遗漏了一些东西.自从我写了它,我就忽略了语法错误.有什么帮助吗?

This code is throwing an error i tried to troubleshoot but I'm missing something . Since I wrote it I'm overlooking a syntax error. Any help ?

$kql="
INSERT INTO References (Email, Company1, Person1, Contact1, Company2, Person2, Contact2, Company3, Person3, Contact3, Company4, Person4, Contact4, Company5, Person5, Contact5)
VALUES ( '$company44','$Company', '$Person', '$Contact', '$Company1', '$Person1', '$Contact1', '$Company2', '$Person2', '$Contact2', '$Company3', '$Person3', '$Contact3', '$Company4', '$Person4', '$Contact4')";

错误是

错误:您的SQL语法有错误;在第1行的参考(电子邮件,Company1,Person1,Contact1,Company2,Person2,Contact2,Com")附近,查看与您的MySQL服务器版本相对应的手册以使用正确的语法.

Error: 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 'References (Email, Company1, Person1, Contact1, Company2, Person2, Contact2, Com' at line 1

推荐答案

REFERENCES是用于定义外键的SQL关键字.

REFERENCES Is a SQL keyword used to define a foreign key.

如果您的表/列名使用SQL关键字命名,则必须将表/列名包装为特定字符.

If you have a table/col named with a SQL keyword, you have to wrap the table/col name into specific characters.

MySQL

INSERT INTO `References` (...) ...

MS SQL

INSERT INTO [References] (...) ...

Postgre SQL

INSERT INTO "References" (...) ...

我不确定pgSQL,有人可以确认吗?

I'm not sure concerning pgSQL, can someone confirm?

例如,没有什么(除了常识)会阻止您使用表INTO具有列VALUE(42)

In example, nothing (but common sense) prevents you from creating a database named INSERT with a table INTO having a column VALUE(42)

此查询有效:

USE [INSERT]
SELECT [INTO].[VALUE(42)] FROM [INTO]

这篇关于PHP数据库插入无法按计划工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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