我正在执行一些查询,并得到以下错误:
Parse error: syntax error, unexpected ‘$section2’ (T_VARIABLE) on line
22
第22行是:
$section2 = $db->prepare("INSERT INTO learning_style_scores VALUES (5,12,4)");
我不知道为什么我得到这个,我检查了我的语法,一切似乎都是正确的.在执行$section1查询后,它基本上不喜欢任何东西
编辑:
我知道这很容易被SQL注入,但我这样做只是为了测试目的.
session_start();
try {
$db = new PDO("mysql:dbname=questionnaire;host=localhost", "root", "");
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch(Exception $e)
{
echo 'Caught exception: ', $e->getMessage(), "
";
}
$session = md5(session_id());
// insert section1 data into database
$section1 = $db->prepare('INSERT INTO section1 VALUES (7,"test")');
$section1->execute();?
// insert learning style score into database
$section2 = $db->prepare("INSERT INTO learning_style_scores VALUES (5,12,4)");
$section2->execute();?
?>