【发布时间】:2014-01-03 10:24:30
【问题描述】:
我到处搜索,找不到答案,我相信我有正确的代码,但可能有错字。
这里出了什么问题?
我有将产品 ID 正确发布到 url 的链接,如下所示:
userAccount.php:
while($columnDelete = mysqli_fetch_array($query, MYSQLI_ASSOC)){
echo "<section class='product'>
<a href='extras/deleteProcess.php?productId=".$columnDelete['productId']."' class='deleteProduct' style='color:#990000;font-family:arial;font-weight:bold;font-size:12pt;background:transparent;'>Delete?</a>
<section class='productImg'>
<a target='_self' href='fullProductInfo.php?productId=".$columnDelete['productId']."'>
<img src='http://www.littlepenguindesigns.co.uk/pages/CMX/images/products/".$columnDelete['productImg']."' alt='".$columnDelete['productName']."' border='0' width='230' height='200' border='0' />
</a>
</section>
<section class='productName'><a target='_self' href='fullProductInfo.php?productId=".$columnDelete['productId']."'>".$columnDelete['productName']."</a></section>
<section class='productPrice'>£".$columnDelete['price']."</section></section>";
}
$columnDelete['productId']; 将正确的 ID 发布到 url 和 deleteProcess.php 页面,我可以在 URL 中看到 productId,并且我也将其回显到页面上进行检查,它确实显示:
deleteProcess.php:
$productId = $_GET['productId'];
$con = mysqli_connect("BLAH","BLAH","BLAH","BLAH") or die('Server connection not possible.');
$sql = ("DELETE FROM `product` WHERE `product`.`productId`= $productId");
mysqli_query($con, $sql);
echo "Deleted product ID: $productId successfully.<br /><br /><br /><br /><br /><br /> <a href='../userAccount.php#deletion'>Go back to user account and delete another.</a>";
我不明白发生了什么,产品被调用到deleteProcess.php 并进入页面但没有删除,它也没有显示错误。由于我对 php 和 mysql 不熟悉,我认为我最好研究一下,因为我想不出任何答案我想问,所以任何人都可以告诉我我做错了什么或指出我正确的方向。
【问题讨论】:
-
检查mysql是否连接
-
echo 查询然后直接运行到 phpmyadmin 看看是什么错误
标签: php mysql delete-row corresponding-records