开发者

Submit Comments to mySQL using Php

开发者 https://www.devze.com 2023-02-23 01:26 出处:网络
PHP <?php // Insert Comments into Database that user provides $comm = mysql_real_escape_string($_POST[\'addComment\']);

PHP

<?php
// Insert Comments into Database that user provides
$comm = mysql_real_escape_string($_POST['addComment']);
$pID4 = filter_input(INPUT_GET, 'pID', FILTER_SANITIZE_NUMBER_INT);
$cID = mysql_real_escape_string($_POST['courseInfoDD']);
        $username = "####";
        $password = "####";
        $pdo4 = new PDO('mysql:host=localhost;dbname=####', $username, $password);
        $pdo4->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
$sth4 = $pdo4->prepare('
    INSERT INTO Comment (info, pID, cID)
    VALUES(:comm, :pID4, :cID);
');
$sth4->execute(array( ':comm' => $comm, ':pID4' => $pID4, ':cID' => $cID, ));

?>

HTML:

<input type='text' id='addComment' name='addComment' tabindex='3' value='Enter comment' />

DB TABLE: http://postimage.org/image/pfkqxpg/

Why isnt this working? Do I need to in开发者_如何学Cclude professor too?? :: http://postimage.org/image/25wsqhap0/

It seem to not like the line: $sth4->execute(array( ':comm' => $comm, ':pIDF' => $pID4, ':cID' => $cID )); do you spot anything wrong? It throws error:

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number: mixed named and positional parameters' in Stack trace: #0  PDOStatement->execute(Array) #1: require_once('/Applications/X...') #2 {main} thrown on line 75

// Moderator Please show pictures since I still dont have rights to


$sth4->execute(array( 'comm' => $comm, 'pID4' => $pID4, 'cID' => $cID, ));

No colons

0

精彩评论

暂无评论...
验证码 换一张
取 消