错误是:
您的SQL语法有错误;检查与您的MySQL服务器版本相对应的手册,以便在#sa; sarojini' _bookings WHERE date = 2014-07-24 AND start = 10:00:00'附近使用正确的语法。在第1行
<?php
session_start();
require ('sql_connect.php');
if (isset($_SESSION['id']) && is_numeric($_SESSION['id']))
{
$id=$_SESSION['id'];
$sql1 = mysql_query("SELECT name FROM lecturer WHERE staff_id ='$id'");
$q = mysql_fetch_array($sql1);
$n = $q['name'];
$sql2 = mysql_query("SELECT * FROM bookings WHERE lecturer_name='$n' ORDER BY date");
$q1 = mysql_fetch_array($sql2);
$d = $q1['date'];
$s = $q1['start'];
$result = mysql_query("DELETE FROM '$n'_bookings WHERE date=$d AND start=$s")
or die(mysql_error());
//header("Location: manageappointment1.php");
}
else
{
//header("Location: manageappointment1.php");
}
?>
答案 0 :(得分:3)
您的查询:"DELETE FROM '$n'_bookings WHERE date=$d AND start=$s"
正确查询:"DELETE FROM ".$n."_bookings WHERE date=$d AND start=$s"
实际上查询是正确的,它只是关于你的var ..
你也可以写:
"DELETE FROM {$n}_bookings WHERE date=$d AND start=$s"
答案 1 :(得分:0)
而不是
$result = mysql_query("DELETE FROM '$n'_bookings WHERE date=$d AND start=$s")or die(mysql_error());
使用
$result = mysql_query("DELETE FROM ".$n."_bookings WHERE date='$d' AND start='$s'")or die(mysql_error());
答案 2 :(得分:-2)
我认为这是因为你使用简单的引用。使用此:
DELETE FROM $n_bookings WHERE date=$d AND start=$s