<?php
$conn=mysqli_connect("localhost","root","root","test");
$sql = "insert into play valuse('$_POST[Account]','$_POST[Password]')";
$result = mysqli_query($conn,$sql);
if($result){
echo"成功";
}else{
echo"失敗";
}
?>
//[form.php]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<form method="POST" action="crud.php">
<h3>New Account</h3>
Account: <input type="text" name="Account"><br>
Password: <input type="text" name="Password"><br>
<input type="submit" value="insert">
</form>
</body>
</html>
在測試時,輸入了account 和password後出現
**"Fatal error: Uncaught mysqli_sql_exception: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'valuse('dhgfh','fgh')' at line 1 in F:\xampp\htdocs\test\crud.php:4 Stack trace: #0 F:\xampp\htdocs\test\crud.php(4): mysqli_query(Object(mysqli), 'insert into pla...') #1 {main} thrown in F:\xampp\htdocs\test\crud.php on line 4"**
新手,一星期編程經驗,求賜教
提示: valuse ??
雖然有最佳解答了
但我建議可以嘗試去看一下錯誤提示
會對之後有很多幫助,畢竟人人皆會犯錯
crud.php on line 4