<?php
include('config.php');
if(isset($_REQUEST["submit"]))
{
$name=$_REQUEST["name"];
$dateofbirth=$_REQUEST["dateofbirth"];
$source=$_REQUEST["source"];
$status=$_REQUEST["status"];
$phoneno=$_REQUEST["phoneno"];
$branch=$_REQUEST["branch"];
mysqli_query("insert into wp_dynamic(name,dateofbirth,source,status,phoneno,branch)values('$name','$dateofbirth','$source','$status','$phoneno','$branch')");
}
?>
答案 0 :(得分:0)
由于您是在单引号内调用变量而不进行串联,因此应该像下面这样
mysqli_query($con,"INSERT INTO TableName (name,dateofbirth,source,status,phoneno,branch)values('".$name."','".$dateofbirth."','".$source."','".$status."','".$phoneno."','".$branch."')");
答案 1 :(得分:0)
您应该定义mysqli连接并在查询中使用它。
<?php
include('config.php');
if(isset($_REQUEST["submit"]))
{
$conn = new mysqli(HOST,USERNAME,PASSWORD,DATABASE);
$name=$_REQUEST["name"];
$dateofbirth=$_REQUEST["dateofbirth"];
$source=$_REQUEST["source"];
$status=$_REQUEST["status"];
$phoneno=$_REQUEST["phoneno"];
$branch=$_REQUEST["branch"];
mysqli_query($conn,"INSERT INTO wp_dynamic (name,dateofbirth,source,status,phoneno,branch) VALUES ('".$name."','".$dateofbirth."','".$source."','".$status."','".$phoneno."','".$branch."')");
mysqli_close($conn);
}
或者您可以使用mysqli_query的此插件:
$insert = "INSERT INTO wp_dynamic (name,dateofbirth,source,status,phoneno,branch) VALUES ('$name','$dateofbirth','$source','$status','$phoneno','$branch')";
if($conn->query($insert)){
echo "Insert successful";
}
else{
echo mysqli_error($conn);
}
mysqli_close($conn);