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