您的SQL语法有错误;检查与MySQL服务器版本对应的手册,以便在“doc_rate”附近使用正确的语法,其中fra_code ='ET7867FRA'和destination ='WITH IN CITY',mode ='S'在第1行##
<?
if(isset($_POST['Submit']))
{
$fra_code = $_POST['fra_code'];
$mode = $_POST['mode'];
$destination = $_POST['destination'];
$receiver = $_POST['receiver'];
// Connect to the database
$con = mysql_connect($dbhost, $dbusername, $dbuserpassword);
// Make sure we connected succesfully
if(! $con)
{
die('Connection Failed'.mysql_error());
}
mysql_select_db($default_dbname);
if ($receiver !="")
{
// The below query is okay when doing with single deletion but when passing variable from it , the error shows
$sql = "DELETE from '".$receiver."' where fra_code='".$fra_code."' and destination='".$destination."' and mode='".$mode."'";
}
else{
echo "<script>alert (\"Reciver Mode Not Selected\");history.go(-1)</script>";
}
try{
$result = mysql_query($sql);
if($result){
echo "<script>alert (\"Wrong Rate List Deleted\");history.go(-1)</script>";
exit;
}
else{
$msg = mysql_error(); // display error so you can fix it
echo "<script>alert (\"$msg\"); history.go(-1)</script>";
}
}
catch (Exception $e)
{
error_reporting (E_ALL ^ E_NOTICE);
echo $e->errorMessage();
}
}
}
?>
答案 0 :(得分:1)
从表名中删除单引号
$sql = "DELETE from $receiver where `fra_code`= '$fra_code' and `destination`= '$destination' and `mode` = '$mode' ";