코드를 사용하여 :이 테이블을 업데이트하는 방법? "INC/Q/prof.php"에 PHP/MySQL의
<?php
// Insert Comments into Database that user provides
$comm = mysql_real_escape_string($_POST['addComment']);
// following line has changed:
$pID4 = filter_var($_POST['pID'], FILTER_SANITIZE_STRING);
$commentDetail = $_POST['addComment'];
$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(?,?,?)
SELECT Comm.cID
FROM Professor P, Comment Comm, Course Cou
WHERE P.pID = Comm.pID
AND Cou.cID = Comm.cID;
');
$sth4->execute(array($commentDetail, $pID4, $cID));
?>
HTML
<form action='inc/q/prof.php' method='post'>
<input type='text' id='addComment' name='addComment' tabindex='3' value='Enter comment' />
<input type='hidden' name='pID' value='<?php echo $pID4; ?>'>
</form>
테이블 :
오류가 계속 수신 됨 - 여전히 오류가 발생합니다. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT Comm.cID FROM Professor P, Comment Comm, Course Cou WHERE P.pID = Comm.p' at line 2\PDOStatement->execute(Array) #1
이렇게하면 Array()가됩니다. 업데이트 된 코드를 참조하십시오. – Jshee