谢谢各位,搞定了,原来是在js中一个单词拼写不正确,总是很简单
这是我将数据写入本地服务器上的数据库的脚本,它目前只写入 2 个字段,而不是别名字段,我做错了什么吗?我已经三次检查了 html 表单和数据库字段中的名称。
<?php
// 1. Create connection to database
mysql_connect('localhost','root','') or die('Could not connect to mysql: <hr>'.mysql_error());
// 2. Select database
mysql_select_db("trialdb") or die('Could not connect to database:<hr>'.mysql_error());
// 3. Assign variables (after connection as required by escape string)
$alias = $_POST['alias'];
$name = $_POST['name'];
$email = $_POST['email'];
// 4. Insert data into table
mysql_query("INSERT INTO user_data (alias, name, email) VALUES ('$alias', '$name', '$email')");
Echo 'Your information has been successfully added to the database.';
print_r($_POST);
mysql_close()
?>