我正在建立一個網站,目的是學習php,在本地開發網站,然後轉移到遠程。根中的一個文件夾是'clients',它由腳本組成,用於列表,插入,更新和刪除表單中的客戶反饋。本地(XAMPP)所有腳本都可以很好地工作。但是,當我將它傳輸到遠程時,一切正常,除了刪除腳本。當我嘗試刪除遠程的條目時,它只是給出了一個未找到頁面的錯誤。我已附上相關的代碼如下。我會很感激的幫助。 1.以下是包含刪除腳本的頁面。PHP刪除腳本只適用於本地,而不適用於遠程
<?php require_once('scripts/db_delete_feedback.php'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Delete Feedback</title>
<link href="../css/admin.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Delete Feedback</h1>
<p><a href="index.php">Admin menu</a></p>
<p>Please confirm that you want to delete the following record. This cannot be undone.</p>
<form id="form1" name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>.">
<p><strong>Client Name:</strong><?php echo $feedback['name']; ?></p>
<p><strong>Feedback summary:</strong><?php echo $feedback['punch']; ?></p>
<p><strong>Rating:</strong><?php echo $feedback['rating']; ?></p>
<?php if ($photos) { ?>
<p>The following photos are linked with this client feedback. Select the checkbox next to each photo you want to delete at the same time as this feedback. To delete images without deleting the feedback, use <a href="list_photos.php">photo management page</a>.</p>
<table width="600">
<?php
$num = 0;
foreach ($photos as $photo) { ?>
<tr>
<td><input type="checkbox" name="photo[]" id="photo<?php echo $num;?>" value="<?php echo $photo['filename']; ?>" />
<label for="photo<?php echo $num++; ?>" class="checkbox_label">Delete photo</label></td>
<td><img src="../images/<?php echo $photo['filename']; ?>" width="200" alt="" /><br /><?php echo $photo['caption']; ?></td>
</tr>
<?php } ?>
</table>
<?php } ?>
<p>
<input type="submit" name="delete_feedback" id="delete_feedback" value="Confirm Deletion" />
<input type="submit" name="cancel" id="cancel" value="Cancel" />
<input name="returnto" type="hidden" id="returnto" value="<?php echo $returnto; ?>" />
<input name="client_id" type="hidden" id="client_id" value="<?php echo $client_id; ?>" />
</p>
</form>
</body>
</html>
下面是上面的腳本包含了 'db_delete_feedback.php' 文件:
<?php $errors = array(); require_once('library.php'); try { require_once('db_definitions.php'); $client_id = checkId('client_id', 'list_feedback.php'); if (isset($_POST['delete_feedback'])) { // delete and redirect $dbWrite->delete('clients', "client_id = $client_id"); $dbWrite->delete('client2photo', "client_id = $client_id"); if (isset($_POST['photo'])) { foreach ($_POST['photo'] as $filename) { $dbWrite->delete('photos', "filename = '$filename'"); unlink($destination . '/' . $filename); } } header('Location: ' . $_POST['returnto']); exit; } elseif (isset($_POST['cancel'])) { header('Location: ' . $_POST['returnto']); exit; } $feedback = getFeedback($dbRead, $client_id); $photos = getRelatedPhotos($dbRead, $client_id); if (isset($_SERVER['HTTP_REFERER'])) { $returnto = $_SERVER['HTTP_REFERER']; } else { $returnto = 'list_feedback.php'; } } catch (Exception $e) { echo $e->getMessage(); }
所包含library.php文件包含路徑Zend框架庫。 請幫忙,因爲我無法找到此問題的原因。
任何想法的人?我已經在php中創建腳本來通過表單插入,更新和刪除條目到數據庫中。除了刪除腳本,所有腳本都可以正常工作。不知何故,似乎數據庫拒絕刪除。刪除腳本在我的本地主機(XAMPP)上正常工作,但不在遠程服務器上。在不執行delete語句的情況下,頁面重定向到調用頁面,在url的末尾添加一個點(。),並且由於該頁面不存在,它將返回404錯誤。 – atomheart