How can i fix Mysql images not found error?

Joined
Nov 21, 2023
Messages
3
Reaction score
0
When try to add images stored in my database and display them in the page it gives me an error message saying: Failed to load resource: the server responded with a status of 404 (Not Found) how can i fix this? Here is the code:
PHP:
<?php
declare(strict_types = 1);                             
require 'includes/connection.inc.php';             
require 'includes/Functions.inc.php';                       

$sql = "SELECT a.id, a.title, a.summary, a.category_id, a.member_id,
               c.name AS category,
               CONCAT(m.forename, ' ', m.surname) AS author,
               i.file     AS image_file,
               i.alt      AS image_alt
          FROM article    AS a
          JOIN category   AS c ON a.category_id = c.id
          JOIN member     AS m ON a.member_id   = m.id
          LEFT JOIN image AS i ON a.image_id    = i.id
         WHERE a.published = 1
      ORDER BY a.id DESC
         LIMIT 6;";                                     
$articles = pdo($pdo, $sql)->fetchAll();               

$sql = "SELECT id, name FROM category WHERE navigation = 1;";
$navigation  = pdo($pdo, $sql)->fetchAll();             


$section     = '';                                     
$title       = 'Creative Folk';                         
$description = 'A collective of creatives for hire';     // Meta description content
?>
<!DOCTYPE html>
    <html>
    <head>
</head>
    <body>
  <main class="container grid" id="content">
    <?php foreach ($articles as $article) { ?>
      <article class="summary">
        <a href="article.php?id=<?= $article['id'] ?>">
          <img src="../uploads/<?= htmlspecialchars($article['image_file']) ?>" alt="<?= htmlspecialchars($article['image_alt']) ?>">
          <h2><?= htmlspecialchars($article['title']) ?></h2>
          <p><?= htmlspecialchars($article['summary']) ?></p>
        </a>
        <p class="credit">
          Posted in <a href="category.php?id=<?= $article['category_id'] ?>">
          <?= htmlspecialchars($article['category']) ?></a>
          by <a href="member.php?id=<?= $article['member_id'] ?>">
          <?= htmlspecialchars($article['author']) ?></a>
        </p>
      </article>
    <?php } ?>
  </main>
    </body>
    </html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top