我有几个表单可以从用户正在查看的表中删除各种行。我正在使用 MYSQL 和 PHP。我在另一个页面上有相同的代码(据我所知),它工作正常。由于某种原因,我无法让我的代码执行。它给出了更新失败的错误。
try
{
$db = new PDO('mysql:host=$hname;dbname=' . $DBname, $DBusername, $DBpassword, array(PDO::ATTR_PERSISTENT => true));
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
}
catch ( Exception $ex )
{
die ( 'Cannot Connect to the Database.' );
}
$delete_equipment_single = "DELETE FROM EquipmentItem
WHERE equipmentID = :equipmentID";
equipment_delete.php
<?php require_once('php/security.php'); ?>
<?php
// Get the ID Tag
if( !isset($_GET['equipmentID'] ))
{
echo "You Didn't Supply a equipmentID - (equipmentID) [ERROR x1]";
exit();
}
require_once('php/database.php');
$equipmentID = htmlspecialchars($_GET['equipmentID']);
// Delete the Equipment
$statement = $db->prepare($delete_equipment_single);
$result = $statement -> execute(array(
':equipmentID' => $equipmentID
));
// Make Sure Everything Worked
if( $result == false )
{
die('Update Failed, Please Check Your Database. [ERROR x2]');
}
echo '<meta http-equiv="Refresh" Content="0; url=display_equipment.php?a=1" />';
?>
致命错误:未捕获的异常“PDOException”和消息“SQLSTATE [42000]:语法错误或访问冲突:delete_equipment.php:16 中的 1065 查询为空”堆栈跟踪:#0 delete_equipment.php(16):PDO->prepare( '') #1 {main} 在第 16 行抛出 indelete_equipment.php
设备ID字符串(8)“E1202612”的 VarDump