Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/270.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 由于';引号';_Php_Mysql - Fatal编程技术网

Php 由于';引号';

Php 由于';引号';,php,mysql,Php,Mysql,我在使用php将值插入mysql数据库时遇到了一个非常奇怪的问题,所以我运行了一个测试,这是最简单的简单插入;以下操作不起作用: <?php include("config.php"); // put the *FULL* path to the file. mysql_query("INSERT INTO 'lms'.'test2' ('trn') VALUES ('17')"); ?> 不需要在查询中封装表,除非它们有空间或是保留字 INSERT INTO 'lms'.'t

我在使用php将值插入mysql数据库时遇到了一个非常奇怪的问题,所以我运行了一个测试,这是最简单的简单插入;以下操作不起作用:

<?php
include("config.php"); // put the *FULL* path to the file.

mysql_query("INSERT INTO 'lms'.'test2' ('trn') VALUES ('17')");

?>

不需要在查询中封装表,除非它们有空间或是保留字

INSERT INTO 'lms'.'test2' ('trn') VALUES ('17')
// This makes no real sense to the db. It should be:
INSERT INTO lms.test2 (trn) VALUES ('17')
如果trn列接受数字,它实际上应该是:

INSERT INTO lms.test2 (trn) VALUES (17)
使用MySQL,可以使用倾斜引号字符来封装名称,但不能封装字符串。要在查询中输入字符串,必须使用正常引号,如

您可以对此进行以下操作:

select `someTable`.`someColumn` from `someTable`
但不是这个:

select someTable.someColumn from someTable where myName=`Tommy`;
正确的用法是:

select someTable.someColumn from someTable where myName='Tommy';

在MySQL中,不能使用
来包围表和列的名称。正确的字符是
`
。另一方面,对于字符串,正确的字符串是
mysql\uuz
已被弃用。请改用MySQLi或PDO。这是我写的一篇关于这个主题的文章,。添加了两个你错过的反勾号。@ypercube谢谢,伙计,现在非常非常醉,所以所有的反勾号、单引号和空格看起来都一样:)
select someTable.someColumn from someTable where myName='Tommy';