@Lavrov95

SQLSTATE[42S22]: Unknown column?

Fatal error: Uncaught PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'math' in 'where clause' in C:\xampp\htdocs\forum\library\Forum.php:42 Stack trace: #0 C:\xampp\htdocs\forum\library\Forum.php(42): PDOStatement->execute() #1 C:\xampp\htdocs\forum\allquestions.php(26): Forum->getQuestion('18') #2 {main} thrown in C:\xampp\htdocs\forum\library\Forum.php on line 42

b423e8f920f342448af729e241396169.png

forum.php
<td><a href="allquestions.php?subject=math&id=<?php echo $userid; ?>">Math</a></td>


allquestions.php
$forum = new Forum();
$question = $forum->getQuestion($_GET['id']);

if (isset($question)) {
    foreach ($question as $key) { ?>
        <div class="question">
            <div>
 <?php
                echo $key['short_description'];
                ?>
 <div>
 <div>
<?php } ?>




Forum.php
public function getQuestion($question_id)
    {
        $subject = (string)$_GET['subject'];
        $sql = "SELECT * FROM forum WHERE subject=$subject";
        $query = $this->db->pdo->prepare($sql);
        $query->bindValue(':question_id', $question_id);
        $query->execute();
        $result = $query->fetchAll();
        return $result;
    }
  • Вопрос задан
  • 1796 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы