我想使用PHP插入數據到MySQL數據庫。據我可以看到我使用正確的代碼,但它沒有插入 - 在phpMyAdmin沒有任何變化。我做錯了什麼? (我在這裏更改了數據庫名和密碼只針對安全性它連接沒有任何問題)插入MySql DB與PHP不工作
使用反引號的<?php
$link = mysqli_connect("localhost", "dbname", "password", "dbname");
if (mysqli_connect_error()) {
die ("Error connecting to the database");
}
$query = "INSERT INTO 'users' ('email', 'password')
VALUES ('[email protected]', '12345678')";
mysqli_query($link, $query);
?>
yheah平面文字的密碼,您將是流行 – nogad
[Little Bobby](http://bobby-tables.com/)說*** [你的腳本存在SQL注入攻擊風險。](http://stackoverflow.com/questions/60174/how-can ***)瞭解[MySQLi](http://php.net/手動/ EN/mysqli.quickstart.prepared -statements.php)。即使[轉義字符串](http://stackoverflow.com/questions/5741187/sql-injection-that-gets-around-mysql-real-escape-string)是不安全的! [不要相信它?](http://stackoverflow.com/q/38297105/1011527) –
**不要存儲純文本密碼!**請使用PHP的[內置函數](http:// jayblanchard。 net/proper_password_hashing_with_PHP.html)來處理密碼安全性。如果您使用的PHP版本低於5.5,則可以使用'password_hash()'[兼容包](https://github.com/ircmaxell/password_compat)。確保你*** [不要越獄密碼](http://stackoverflow.com/q/36628418/1011527)***或在哈希之前使用其他任何清理機制。這樣做*更改密碼並導致不必要的附加編碼。 –