PHP update() function not working
I am developing a web application and need to update database entries as per user requirements via forms. I am using the Savant templating engine for the MVC structure. All was going fine till I went on to test the update()
function. When I filled the update form and clicked the update button, it led to a blank screen with the URL of update.php. Here's the code of the Update.php page:
<?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;
}
}
?>
I think that the problem is, most probably, somewhere in the above code. In case you wish to see the update()
function in the m开发者_运维技巧odel, here it is:
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();
}
Please help in case you have any information. This is important! Thanks in advance. :)
As I specified under the comments under the question, I got my problem solved as I realized that I was missing a pair of parenthesis after the validate()
function. Cheers.
精彩评论