-5

我收到错误消息:“您的 SQL 语法有错误;请查看与您的 MySQL 服务器版本相对应的手册,以便在第 2 行的 'rs)' 附近使用正确的语法”

这是我的代码:

<div id="main" >
<form name="form1" method="POST" >
<div id="input" align="center">
<table width="700" border="1">
<tr>
<td>Seat Preference</td>
<td>Zone</td>
<td>Meal Preference</td>
<td>Medical Considerations</td>
<td>Dietary Considerations</td>
</tr>
<tr>
 <td>&nbsp;<select name="seat">
<option>Window Seat</option>
<option>Aisle Seat</option>
</select></td>
<td>&nbsp;<select name="zone">
<option>Smoking</option>
<option>Non-Smoking</option>
</select></td>
<td>&nbsp;<select name="meal">
<option>Vegetarian</option>
<option>Non-Vegetarian</option>
</select></td>
<td>&nbsp;<input type="text" name="medical"/></td>
<td>&nbsp;<input type="text" name="dietary"/></td>
</tr>
</table>
</div>
<div id="button" align="center" >
<input type="submit" value="Take Fare and Proceed" name="submit"/>
</div>
</form>
<?php
mysql_connect("127.0.0.1","root","");
mysql_select_db("cmc");

     if (isset($_POST["submit"]))
{

$r=mysql_query("select * from reservation where transid=".$_REQUEST["id"].""); $d=mysql_fetch_assoc($r);
then query is::

mysql_query("INSERT INTO                         
      manifest(`day`,`month`,`year`,`class`,`sector`,`seat`,`zone`,`meal`,`medical`,`dietary`,`fare`)
VALUES(".$d["day"].",'".$d["month"]."','".$d["year"]."','".$d["class"]."','".$d["sector"]."         ','".$_POST["seat"]."','".$_POST["zone"]."','".$_POST["meal"]."','".$_POST["medical"]."','"    .$_POST["dietary"]."',".$d["fare"].")
    ") or die(mysql_error());

进一步的代码是:

 header("Location: print.php");

$dnew=$d["availibilty"]-1;
mysql_query("update reservation set availibility=".$dnew."");
header("Location: print.php");
 }
?>
</div>

我找不到错误。这是航空公司在线预订的 php 代码

4

4 回答 4

1

您的错误在这一行:

mysql_query("INSERT INTO                         
      manifest(`day`,`month`,`year`,`class`,`sector`,`seat`,`zone`,`meal`,`medical`,`dietary`,`fare`)
VALUES(".$d["day"].",'".$d["month"]."','".$d["year"]."','".$d["class"]."','".$d["sector"]."         ','".$_POST["seat"]."','".$_POST["zone"]."','".$_POST["meal"]."','".$_POST["medical"]."','"    .$_POST["dietary"]."',".$d["fare"].")
    ")

注意它的最后一点看起来像这样:

"',".$d["fare"].") ")

但是值周围没有引号。因此,您需要将其更改为:

"','".$d["fare"]."') ")
于 2012-07-08T06:07:16.100 回答
0

如果适合您,请尝试以下操作。

$r=mysql_query("select * from reservation where transid='".$_REQUEST['id']."'"); $d=mysql_fetch_assoc($r);

编辑:

mysql_query("INSERT INTO                         
      manifest(`day`,`month`,`year`,`class`,`sector`,`seat`,`zone`,`meal`,`medical`,`dietary`,`fare`)
VALUES('".$d['day']."','".$d['month']."','".$d['year']."','".$d['class']."','".$d['sector']."         ','".$_POST['seat']."','".$_POST['zone']."','".$_POST['meal']."','".$_POST['medical']."','"    .$_POST['dietary']."','".$d['fare']."')") or die(mysql_error());
于 2012-07-08T06:25:30.187 回答
-1

这将有助于:(最佳实践)
将 Query String 放入一个变量并显 Query 以检查是否将正确的 Query 传递给mysql_query().

在phpmyadmin(或您的 mysql 编辑器)中Query打印后。run it它会告诉你什么是深度错误。

于 2012-07-08T05:48:38.043 回答
-1

您似乎没有指向包含错误的正确代码,因为我在您的 SQL 中找不到“rs)”。

确保您向我们提供了正确的 SQL 请求。

于 2012-07-08T05:49:52.773 回答