【发布时间】:2014-02-25 10:59:45
【问题描述】:
我想在我的数据库表中插入多个变量为VALUES。这是我的代码
include 'database_connect.php';
$namef= $_post["fnam"];
$lnamel= $_post["lnam"];
$addres= $_post["addres"];
$mail= $_post["email"];
$countr= $_post["countr"];
$db= $_post["do"];
$m= $_post["m"];
$pasword= $_post["pas"];
$insertSql= "INSERT INTO abcd(Id, First_name, Last_name, Address, Email, Country, Date_of_birth, Mobile_number, Password, Status)
VALUES(NULL,'$namef', '$namel', '$addres', '$mail', '$countr', '$db', '$m', '$pasword', '0')";
if(mysql_query($insertSql))
header("location: login_success.php");
else
header("location: wrong_inf.php");
这里仅在 Id 和状态字段中插入,所有其他字段都为空,即使我在这些输入中提供了一些输入。
我不知道如何解决这个问题。
注意:这里Id 是integer 类型,status 是tinyint 类型,所有其他字段都是varchar 类型。
【问题讨论】:
-
试试 print_r($_POST) ,它说了什么?
-
尝试将
$_post[""]更改为$_POST[''] -
您将 ID 设置为 NULL 似乎很奇怪。这真的是你想做的吗?
-
请务必仔细阅读并理解这一点:stackoverflow.com/questions/60174/… 这将有助于防止您的数据库被黑客入侵。
标签: php mysql sql sql-server