SQL准备语句未运行?

时间:2018-10-29 17:31:40

标签: php mysql sql session

我从应该提交评论的主页通过AJAX异步运行了以下.php文件:

<?php
session_start();
include "dxbase.php";
$conn = new mysqli($servername, $username, $password, $dbname);



    $comment = "practice";
    $prid = 2;

    if(isset($_SESSION['user'])){

    $usera = $_SESSION['user'];


    $stmt = $conn->prepare("INSERT INTO reviews (prid, content, username) VALUES (?, ?, ?)");
    $stmt->bind_param("sss", $prid, $comment, $usera);
    $stmt->execute();
    echo "Review submitted!";
    $stmt->close();




    } else {
        echo "Oops! You need to be signed in to review products!";



    }
    $conn->close();
?>

当我运行它时,它回显它已提交评论,但是当我检查数据库时,它不在:DB

为什么不插入?!

0 个答案:

没有答案