目前正在使用 php 脚本和 sql 数据库。一切似乎都可以正常工作,即使在最后呼应用户名时,它似乎也是成功的。当进一步查看数据库中的插入时,未插入行。没有错误消息,插入语句准确地反映了列......有什么想法吗?
<?php
$db_name = "animator"; // Database name
$link = mysql_connect('localhost', 'root', 'admin');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db($db_name) or die("Could not connect to Database" .mysql_error());
$username = $_POST['fname'];
$passwords = $_POST['pass'];
$email = $_POST['email'];
mysql_query($link,"INSERT INTO 'account'('username', 'passwords', 'email') VALUES
($username , $passwords , $email)");
mysql_close($link);
?>
***更新* *** 非常感谢大家的回复。我终于能够使用我发现的另一种技术让它工作。
<?php
error_reporting(E_ALL);
ini_set('display_errors',"On");
$db_name = "animator"; // Database name
$link = mysql_connect('localhost', 'root', 'admin');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
//echo 'Connected successfully';
mysql_select_db($db_name) or die("Could not connect to Database" .mysql_error());
$username = $_POST['fname'];
$passwords = $_POST['pass'];
$email = $_POST['email'];
$query = "INSERT INTO account (username, passwords, email) VALUES ('$username',
'$passwords', '$email')";
$result = mysql_query($query);
echo $username;
mysql_close($link);
?>