我有错误 SQLSRV:',' 附近的语法不正确
I have error SQLSRV : Incorrect syntax near ','
SQLSTATE: 42000 code: 102 message: [Microsoft][ODBC Driver 11 for SQL
Server][SQL Server]Incorrect syntax near ','.
我的代码,我使用 PHP 连接 sqlsrv:
if(isset($_POST['smlogin']))
{
$namef = $_POST['fulname'];
$user = $_POST['emailz'];
$pass = $_POST['pswz'];
$md5pass = md5($pass);
$chondl = "select * from Accounts WHERE email={$user} , MD5Password={$pass}";
$nhap = sqlsrv_query($conn, $chondl);
if($nhap)
{
echo'<script>alert("Done!"); </script>';
}
else
if( ($errors = sqlsrv_errors() ) != null) {
foreach( $errors as $error ) {
echo "SQLSTATE: ".$error[ 'SQLSTATE']."<br />";
echo "code: ".$error[ 'code']."<br />";
echo "message: ".$error[ 'message']."<br />";
}
}
}
求求你帮忙:)
您需要在查询中替换以下内容
$chondl = "select * from Accounts WHERE email={$user} , MD5Password={$pass}";
替换后
$chondl = "select * from Accounts WHERE email='$user' AND MD5Password='$pass'";
SQLSTATE: 42000 code: 102 message: [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Incorrect syntax near ','.
我的代码,我使用 PHP 连接 sqlsrv:
if(isset($_POST['smlogin']))
{
$namef = $_POST['fulname'];
$user = $_POST['emailz'];
$pass = $_POST['pswz'];
$md5pass = md5($pass);
$chondl = "select * from Accounts WHERE email={$user} , MD5Password={$pass}";
$nhap = sqlsrv_query($conn, $chondl);
if($nhap)
{
echo'<script>alert("Done!"); </script>';
}
else
if( ($errors = sqlsrv_errors() ) != null) {
foreach( $errors as $error ) {
echo "SQLSTATE: ".$error[ 'SQLSTATE']."<br />";
echo "code: ".$error[ 'code']."<br />";
echo "message: ".$error[ 'message']."<br />";
}
}
}
求求你帮忙:)
您需要在查询中替换以下内容
$chondl = "select * from Accounts WHERE email={$user} , MD5Password={$pass}";
替换后
$chondl = "select * from Accounts WHERE email='$user' AND MD5Password='$pass'";