0
我正在開發一個Web應用程序,並需要根據用戶需求通過表單更新數據庫條目。我爲MVC結構使用了Savant模板引擎。一切都很順利,直到我繼續測試update()
函數。當我填寫更新表單並單擊更新按鈕時,它導致了一個空白屏幕,其URL爲update.php。下面是Update.php頁面的代碼:
PHP更新()函數不工作
<?php
include_once("../../Resources/Libraries/Savant3.php");
include_once("../../Classes/Models/Test.php");
$s=new Savant3();
$s->method=$_SERVER['REQUEST_METHOD'];
if($_SERVER['REQUEST_METHOD']=="GET")
{
$b=Test::readSingle($_GET['id']);
$s->b=$b;
$s->display("UpdateView.tpl");
}
else
{
$b=new Test();
$b->id= $_POST['id'];
$b->title= $_POST['title'];
$b->address= $_POST['address'];
$b->location= $_POST['location'];
if($b->validate==true)
{
Test::update($b);
header('location: ../../Applications/Success');
return;
}
}
?>
我覺得現在的問題是,最有可能,在上面的代碼的某個地方。如果你希望看到在模型中update()
功能,那就是:
public static function update(Test $b)
{
$id=$b->id;
$title=strip_tags($b->title);
$address=strip_tags($b->address);
$location=strip_tags($b->location);
$m=new mysqli("localhost", "XXXXXXXX", "XXXXXXXXXXX", "XXXXXXXXXXX");
$s=$m->prepare("update test set title=?, post=?, location=? where id=?");
$s->bind_param("sssi", $title, $address, $location, $id);
$s->execute();
}
請幫情況下你有任何的信息。這個很重要!提前致謝。 :)
你的服務器的錯誤日誌說什麼? – ceejayoz 2011-02-15 18:47:24