我正在尝试使用准备好的stmt以避免sql注入,并且它无法正常工作。我已经用一些警报语句包围了我的代码,以了解问题出在哪里。它位于bind_param语句中。之后的所有事情都永远不会执行。希望我能找到帮助!过去3个小时一直在寻找答案,到目前为止,还没有任何解决方案。PS表有6列。一个ID会自动递增,其余的就像你从代码中看到的那样$db = new PDO("mysql:port=3302;dbname=thedoctors", "root", ""); $Data = $_POST["post"];$postData = $db->quote($_POST["post"]); //user's post$user = $db->quote($_SESSION["user"]); //user's email$stmt = $db->prepare("INSERT INTO post (body,timee,likes,comments,userem) VALUES (?, NOW(), ?, ?, ?);");// set parameters and execute$first = ".$postData.";$like = 0;$comment = 0;$stmt->bind_param("siis", $first, $like, $comment, $user);echo "<script>alert('hello');</script>";// $result = $stmt->get_result();// header("location:activity.php");if (strlen($Data) > 3000 || strlen($Data) < 1) { echo "<script>alert('Make sure your post is of correct length!');</script>";} else { $stmt->execute(); echo "<script>alert('Post uploaded! You can check it in your profile!');</script>";}
1 回答
- 1 回答
- 0 关注
- 176 浏览
添加回答
举报
0/150
提交
取消