Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 在mySQL和JSP中使用URL参数时出错_Html_Mysql_Jsp - Fatal编程技术网

Html 在mySQL和JSP中使用URL参数时出错

Html 在mySQL和JSP中使用URL参数时出错,html,mysql,jsp,Html,Mysql,Jsp,该代码连接到mySQL数据库并生成一个表,用数据填充该表。每行都有一个特定于该行的“购买”按钮。因此,特定的项目代码被发送到jsporder.jsp页面 <sql:query var="result"> select * from inventory; </sql:query> <table border="1" width="100%"> <tr> <th>Code</th> <th>Author</t

该代码连接到mySQL数据库并生成一个表,用数据填充该表。每行都有一个特定于该行的“购买”按钮。因此,特定的项目代码被发送到jsporder.jsp页面

<sql:query var="result">
select * from inventory;
</sql:query>

<table border="1" width="100%">
<tr>
<th>Code</th>
<th>Author</th>
<th>Description</th>
<th>Other field(Probs price)</th>
<th>Item Stock</th>
<th>Order Stock</th>
<th>Buy option </th>
</tr>

<c:forEach var = "row" items = "${result.rows}">
<tr>
<td><c:out value = "${row.item_code}"/></td>
<td><c:out value = "${row.item_author}"/></td>
<td><c:out value = "${row.item_description}"/></td>
<td><c:out value = "${row.item_price}"/></td>
<td><c:out value = "${row.item__stock_count}"/></td>
<td><c:out value = "${row.item_order_count}"/></td>
<td><a href="jsporder.jsp?item_code=${row.item_code}">Buy!</a></td>
<td><a
</tr>
</c:forEach>
</table>
</div>  
我想它从上一页得到了项目代码

现在我需要更改mySQL查询:

<sql:update var="count">
      <%-- update inventory - take one item from stock --%>
      update inventory set item__stock_count = item__stock_count - 1
        where item_code="${itemCode}"; //This is set to the itemCode variable
    </sql:update>

将您的购买链接更改为

<a href="jsporder.jsp?itemCode=${row.item_code}">Buy!</a>
此外,您可能需要在更新查询中使用逗号

  insert into customer_order values
    ( '${param.itemCode}', "2015-02-24 11:42:30", 1, 
                         ^
      "2015-02-25 11:42:30", 5789 );

验证您的
customer\u order
表是否有五列,并且数据类型是否匹配。

此代码似乎不起作用。
。您得到的确切信息是什么。正确解释?@singhakash抱歉,编辑了它。@singhakash 100%执行,多次检查了数据库。错误可能是它正在提取字符串中的项目代码(因为它有引号),例如,如果我在项目代码上单击buy:A001-1111,SQL/JSP会将其提取为“A001-1111”,因此它与数据库中的值不匹配吗?是的,您必须
“${itemCode}”
将其放在单个quotes@singhakash还有错误,,在edit中添加了更多代码,感谢您的回复。解决方案仍然不起作用,这是非常恼人的,因为我已经尝试了2个小时来解决这个问题,而不是打印项目代码,它只是显示“,”。我已经检查了mysql脚本,所有内容都匹配使用
${param.itemCode}
引用该值。如果查询仍然失败,请发布表结构:列名和类型。这就完成了。最后非常感谢。
insert into customer_order values ( '' "2015-02-24 11:42:30", 1, "2015-02-25 11:42:30", 5789 ); : Column count doesn't match value count at row 1"
<a href="jsporder.jsp?itemCode=${row.item_code}">Buy!</a>
String itemCode = request.getParameter("item_code");
  insert into customer_order values
    ( '${param.itemCode}', "2015-02-24 11:42:30", 1, 
                         ^
      "2015-02-25 11:42:30", 5789 );