我也收到此错误:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' , , '',128745)' at line 1
我已经使用过isset()
和!empty()
功能。我所有的变量都在使用之前被声明。我也搜索了很多,仍然无法解决这个问题。请帮助我。我被困在这里。任何帮助对我都有很大用处。谢谢。
这是代码:
<?php
$authorized = false;
session_start();
include('config.php');
if(isset($_SESSION['crnumbers']) && isset($_SESSION['passwords']))
{
$authorized = true;
if(isset($_POST["submit"]) && !empty($_POST["submit"]))
{
$ScdDate = mysql_real_escape_string($_POST['ScdDate']);
$ScdMonth = mysql_real_escape_string($_POST['ScdMonth']);
$ScdYear = mysql_real_escape_string($_POST['ScdYear']);
$DName = mysql_real_escape_string($_POST['DName']) ;
$ScdTime = mysql_real_escape_string($_POST['ScdTime']);
}
$crnumber = mysql_real_escape_string($_SESSION['crnumbers']);
$sql = mysql_query("INSERT INTO schedule(ScdDate,ScdMonth,ScdYear,ScdTime,crnumber,DName)VALUES($ScdDate, $ScdMonth, $ScdYear, '$ScdTime', $crnumber, '$DName')");
if(!$sql)
{
die('There is some error. Damn it! ' .mysql_error());
}
header("location: http://localhost/Alok/Health%20Care%20Project\GUI\patientGUI2.php");
}
else if(!$authorized)
{
header("location:");
exit();
}
?>