1 回答
TA贡献2021条经验 获得超8个赞
您可以尝试以这种方式使用您的查询
$pdo = new PDO('mysql:host=localhost;dbname=liste_course;charset=utf8', 'root', '', [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC
]);
//$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$query = $pdo->prepare("INSERT INTO content(id, title_content, products_content, comments_content) VALUES('','$title','$products','$comments')");
$query->execute();
绑定参数也更安全
$query = $pdo->prepare("INSERT INTO content(id, title_content, products_content, comments_content) VALUES(:id,:title,:products,:comments)");
$query->bindParam(":id", $id);
$query->bindParam(":title", $title);
$query->bindParam(":products", $products);
$query->bindParam(":comments", $comments);
$query->execute();
- 1 回答
- 0 关注
- 111 浏览
添加回答
举报