我試圖理解這種錯誤插入SQL值,但我不如何解決呢 這是我的JS代碼:無法通過AJAX的PHP
$.ajax({
url: 'C:\\inetpub\\wwwroot\\VisionwareHelp\\Php/CriaUserEempresa.php',
type: "POST",
data: ({Pname: Pname, Uname: Uname, email: email, Ename: Ename, Sigla: Sigla}),
complete:function(data)
{
resposta = data;
console.log(resposta);
}
});
這是我的PHP代碼:
$serverName = $server;
$uid = $uid;
$pwd = $pass;
$connectionInfo = array("UID" => $uid, "PWD" => $pwd,"Database"=>"Portal");
//$connectionInfo = array("Database"=>"Portal");
$conn = sqlsrv_connect($serverName, $connectionInfo);
$Pname = $_POST["Pname"];
$Uname = $_POST["Uname"];
$email = $_POST["email"];
$Ename = $_POST["Ename"];
$Sigla = $_POST["Sigla"];
if($conn)
{
$sqlCliente = "INSERT INTO Portal.dbo.Empresa VALUES ($Ename, $Sigla)";
if (mysqli_query($conn, $sqlCliente)) {
echo "New record created successfully";
} else {
echo "Error: " . $sqlCliente . "<br>" . mysqli_error($conn);
}
}
什麼是錯我的代碼?
,沒有u得到任何錯誤? – user3040610
與此相關的HTML表單呢? –
您的查詢中也有語法錯誤。 'mysqli_error($ conn);'應該把東西扔給你;它是什麼?我知道它是什麼,我們需要「你」來告訴我們。哦,你可以在這裏看到一些主要的SQL注入。 –