ВОПРОС: Почему я получаю Call to undefined function prepare()
ошибку?
Как я могу это исправить?
Я знаю , это похоже на мой вопрос, но я не знаю, как применить ответ к моему делу.
$myNull = null;
$table="test_results";
$sql = "INSERT INTO $table (instance, uid, testid, quizstart, quizend, score)
VALUES (
:instance,
:uid,
:testid,
:quizstart,
:quizend,
:score)";
try {
/*** connect to DB ***/
$dbh = new PDO("mysql:host=$hostname;dbname=$dbname", $username, $password);
$stmt = $dbh>prepare($sql); // **************ERROR HERE****************
$stmt->bindParam(':instance', $myNull, PDO::PARAM_INT);
$stmt->bindParam(':uid',$userID, PDO::PARAM_INT);
$stmt->bindParam(':testid', $tid, PDO::PARAM_STR);
$stmt->bindParam(':quizstart', $quizstart,PDO::PARAM_STR);
$stmt->bindParam(':quizend', $quizend,PDO::PARAM_STR);
$stmt->bindParam(':score', $score,PDO::PARAM_STR);
$stmt->execute();
/*** display the id of the last INSERT ***/
$lastInsertValue=$dbh->lastInsertId();
$stmt->closeCursor();
/*** close the database connection ***/
$dbh = null;
}