<?php
$assignmentsTable = $ssubjectnamewithoutspace.'_assignments';
try {
$stmt = $db->query('SELECT contentID, contentTitle,contentAuthor, contentLink FROM .$assignmentsTable ORDER BY contentID ASC');
while($row = $stmt->fetch()){
echo '<tr><td><a href="'.$row['contentLink'].'">'.$row['contentTitle'].'</a></td></tr>';
}
} catch(PDOException $e) {
echo $e->getMessage();
}
?>
我收到此错误
SQLSTATE [42S02]:找不到基表或视图1146表 'epiz_5453564654654_newdata。$ assignmentsTable'不存在
但是表存在于数据库中,当我将$assignmentsTable
替换为表名时,它就起作用了...
答案 0 :(得分:1)
$ assignmentsTable在您的查询中不评估。
尝试:
$stmt = $db->query('SELECT contentID, contentTitle,contentAuthor, contentLink FROM `'.$assignmentsTable.'` ORDER BY contentID ASC');