当我尝试输入较长的文本时出现奇怪的错误,但它适用于一个简单的句子,下面是我的代码:
function insert($project)
{
if (!empty($project->get_title()) && !empty($project->get_description()) && !empty($project->get_imgPath())) {
include 'openConnection.php';
// prepare and bind
$stmt = $dbLink->prepare("INSERT INTO projects (title, description, imgPath) VALUES (?,?,?)");
$stmt->bind_param("sss", $project->get_title(), $project->get_description(), $project->get_imgPath());
// execute
if ($stmt->execute()) {
return $stmt->insert_id;
} else {
$this->addError("Insert failed");
return false;
}
} else {
$this->addError("All fields must be provided");
}
}
下面这个调用上面传递项目的insert方法:
$project = new Project();
$project->set_title($_POST['title']);
$project->set_description($_POST['description']);
$project->set_imgPath($uploadfile);
$project->insert($project);
HUWWW