0

我为我的画廊做了一个评论部分,但不确定为什么只能对它做 1 条评论,然后它就不允许我对该项目执行任何评论

插入

public function insertComment() {
    if(!get_magic_quotes_gpc()) {
        $this -> sanitizeInput();   
    }        
    extract($_POST);

    $name = $_SESSION['userName'];
    $comment = $_POST['comment'];
    $productID = $_GET['id'];

    echo $name;
    echo $comment;
    echo $productID;


    $qry = "INSERT INTO comments VALUES (NULL, '$name', '$comment', '$productID' )";

    $rs = $this -> db -> query($qry);

    if($rs && $this -> db -> affected_rows > 0) {
        $msg = 'comment record created. ';
        } else {
        echo 'Error inserting comment';
    }
    return $msg;      
}

Field   Type    Collation   Attributes  Null    Default Extra   Action
    id  int(11)         No  None    auto_increment                          
    name    varchar(150)    latin1_swedish_ci       No  None                                 
    comment varchar(150)    latin1_swedish_ci       No  None                                 
    productID   int(11)         No  None
4

1 回答 1

0

也许这会奏效

$qry = "INSERT INTO comments (name, comment, productID) VALUES ('$name', '$comment', '$productID' )";

删除空

于 2013-05-02T21:32:08.693 回答