我有一個非常奇怪的問題,插入值到我的MySQL數據庫,使用php,所以我正在運行測試,最簡單的插入;以下不工作:數據沒有插入到mysql數據庫中,因爲引用不同
<?php
include("config.php"); // put the *FULL* path to the file.
mysql_query("INSERT INTO 'lms'.'test2' ('trn') VALUES ('17')");
?>
不過了以下工作:(注意單引號的區別)
<?php
include("config.php"); // put the *FULL* path to the file.
mysql_query("INSERT INTO `lms`.`test2` (`trn`) VALUES ('17')");
?>
我實在看不出有什麼問題,我能得到和幫助,請
在MySQL中,你不能使用'''包圍表和專欄的名字。正確的字符是'\''。另一方面,對於字符串,正確的是'''。 – Adi 2012-08-02 12:11:08
'mysql_'已被棄用。請改用MySQLi或PDO。這是一篇關於該主題的文章,http://anuary.com/54/input-sanitization-and-escaping-for-database-and-stdout-using-php。 – Gajus 2012-08-02 12:30:52