當我嘗試輸入較長的文本時出現奇怪的錯誤,但它適用于一個簡單的句子,下面是我的代碼: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);
1 回答

HUWWW
TA貢獻1874條經驗 獲得超12個贊
我認為錯誤可能是您的數據庫對字符串的字符數有限制。如果您嘗試插入一個長度超過限制的字符串,您的數據庫可能會給您一個錯誤并且不接受該行。我建議查看表結構并查看該列是否指定了字符限制。
- 1 回答
- 0 關注
- 83 瀏覽
添加回答
舉報
0/150
提交
取消