不在php中插入值具有uniqid函数和mysql\u insert\u id
由于您使用的是单引号,数组不会检测到var,因此它会直接在数据库中引入$\u POST[Control\u no] 你应该这样做:不在php中插入值具有uniqid函数和mysql\u insert\u id,php,mysql,insert,Php,Mysql,Insert,由于您使用的是单引号,数组不会检测到var,因此它会直接在数据库中引入$\u POST[Control\u no] 你应该这样做: $q = "INSERT INTO `client_t`(`Control_no`, `Client_id`, `Fname`, `Mname`, `Lname`, `Religion`, `Citizenship`, `Address`, `E-mail`, `Monthly_Income`, `Detained`, `Date_detained`, `Age`,
$q = "INSERT INTO `client_t`(`Control_no`, `Client_id`, `Fname`, `Mname`, `Lname`, `Religion`, `Citizenship`, `Address`, `E-mail`, `Monthly_Income`, `Detained`, `Date_detained`, `Age`, `Gender`, `Civil_Status`, `Educ_attain`, `Language`, `Contact_no`, `Spouse`)
VALUES ('$_POST[Control_no]','$_POST[Client_id]',$_POST[Fname]','$_POST[Mname]'
,'$_POST[Religion]','$_POST[Citizenship]','$_POST[Address]','$_POST[Email]',$_POST[Monthly_Incom]','$_POST[Detained]','$_POST[Date_Detained]','$_POST[Age]','$_POST[Gender]',$_POST[Civil_Status]','$_POST[Educ_Attain]','$_POST[Language]','$_POST[Contact_no]','$_POST[Spouse]')";
$r = mysql_query( $db,$q);
这样,您就可以在$\u POST后面加上双引号,因为如果不在双引号之间键入,它将被读取为常量。添加此项,它将告诉您错误所在
$q = "INSERT INTO `client_t`(`Control_no`, `Client_id`, `Fname`, `Mname`, `Lname`, `Religion`, `Citizenship`, `Address`, `E-mail`, `Monthly_Income`, `Detained`, `Date_detained`, `Age`, `Gender`, `Civil_Status`, `Educ_attain`, `Language`, `Contact_no`, `Spouse`)
VALUES ('" . $_POST["Control_no"] . "','" . $_POST["Client_id"] . "','" . $_POST["Fname"] . "','" . $_POST["Mname"] . "','" . $_POST["Religion"] . "','" . $_POST["Citizenship"] . "','" . $_POST["Address"] . "','" . $_POST["Email"] . "','" . $_POST["Monthly_Incom"] . "','" . $_POST["Detained"] . "','" . $_POST["Date_Detained"] . "','" . $_POST["Age"] . "','" . $_POST["Gender"] . "','" . $_POST["Civil_Status"] . "','" . $_POST["Educ_Attain"] . "','" . $_POST["Language"] . "','" . $_POST["Contact_no"] . "','" . $_POST["Spouse"] . "')";
$\u POST[Control\u no]=$Control\u no$_POST[控制编号]=uniqid$_POST[Client_id]=$Client_id$_POST[Client_id]=uniqid;我可以马上告诉你,这个mysql_查询$db,$q失败了。POST数组的来源未知,用于连接的mysql api也未知。你还有语法错误。使用php的错误报告并检查查询中的错误。您还将面临非常严重的sql注入。您应该为此使用准备好的语句。
If ($r)
{
Echo 'success'
Else
{
Echo Mysql_error();
}