相关疑难解决方法(0)

mysql中的SQL语法错误

我正在从我的MySQL表中插入值php:

$journey = $_POST['way'];
$from = $_POST['from'];
$to = $_POST['to'];
$dpdt = $_POST['dp_date'];
$rtdt = $_POST['rt_date'];
$fare = $_POST['fare'];
$sql = "insert into tours set " .
        "journey='$journey', from='$from', to='$to', dp_date=CAST('$dpdt' AS DATE), " .
        "rt_date=CAST('$rtdt' AS DATE), fare='$fare'";
Run Code Online (Sandbox Code Playgroud)

在努力echo$sql我得到输出:

insert into tours set journey='round', from='Aurangabad', to='Kashmir', dp_date=CAST('27-08-2013' AS DATE), rt_date=CAST('21-08-2013' AS DATE), fare='2500'
Run Code Online (Sandbox Code Playgroud)

但我不断得到相同的错误信息:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for …
Run Code Online (Sandbox Code Playgroud)

php mysql sql

-3
推荐指数
1
解决办法
98
查看次数

标签 统计

mysql ×1

php ×1

sql ×1