Ga naar inhoud

Class not found


Aanbevolen berichten

Hallo

Ik krijg steeds volgende foutmelding bij het opstarten van mijn pagina:

Fatal error: Class 'News' not found in D:\www\kfcherenthout.be\www\Joren\classes\NewsDB.php on line 82

NEWSDB.php:

<?phpini_set( 'display_errors', 1 );error_reporting( E_ALL | E_STRICT );
require_once 'News.php';require_once 'include/config.php';require_once 'include/functions.php';
function connect( &$connectie ){    $connectie = mysql_connect( "mysql.datebasenaam", "Gebruikersnaam", "paswoord" );    if ( !$connectie )    {        die( 'Could not connect: ' . mysql_error() );    }    mysql_select_db( "kfcherenthoutbe", $connectie );    $sql = 'SET NAMES utf8';    mysql_query( $sql, $connectie );}
class NewsDB{    private $connectie;
   public function __construct( )    {        connect( $this->connectie );    }
   public function __destruct ( )    {    }
   public function createNews( $news )    {        $sql = "INSERT INTO                  News                VALUES                (                    '" . escape( $news->getTitle() ) . "',                    '" . escape( $news->getDescription() ) . "',                    '" . escape( $news->getCreated() ) . "',                    '" . escape( $news->getImage() ) . "'                )";        if ( !mysql_query( $sql, $this->connectie ) )        {            die( 'Error: ' . mysql_error() );        }        return mysql_insert_id();    }
   public function upcreatedNews( $news )    {        $sql = "UPDATE                  News                SET                  title = '" . escape( $news->getTitle() ) . "',                  description = '" . escape( $news->getDescription() ) . "',                  created = '" . escape( $news->getCreated() ) . "',                  image = '" . escape( $news->getImage() ) . "'                WHERE                  id = '" . escape( $news->getid() ) . "'";        if ( !mysql_query( $sql, $this->connectie ) )        {            die( 'Error: ' . mysql_error() );        }    }
   public function deleteNews( $id )    {        $sql = "DELETE FROM                  News                WHERE                  id = '" . escape( $id ) . "'";        if ( !mysql_query( $sql, $this->connectie ) )        {            die( 'Error: ' . mysql_error() );        }    }
   public function getNews( )    {        $list = array();        $sql = "SELECT                  *                FROM                  News";        $result = mysql_query( $sql, $this->connectie );        while ( $row = mysql_fetch_array( $result ) )        {            $news = new News( $row['id'], $row['title'], $row['description'], $row['description_large'], $row['created'], $row['image'] );            $list[] = $news;        }        return $list;    }
   public function getNewsById( $id )    {        $sql = "SELECT                  *                FROM                  News                WHERE                  id = '" . escape( $id ) . "'";        $result = mysql_query( $sql, $this->connectie );        $count = mysql_num_rows( $result );        if ( $count == 1 )        {            $row = mysql_fetch_array( $result );            $news = new News( $row['id'], $row['title'], $row['description'], $row['description_large'], $row['created'], $row['image'] );            return $news;        }        else        {            return null;        }    }}?>

News.php

<?php    class News    {               private $id;               private $title;               private $description;               private $description_large;               private $created;               private $image;
          public function __construct ($id, $title, $description, $description_large, $created, $image)    {                       $this->id = $id;                       $this->title = $title;                       $this->description = $description;                      $this->description_large = $description_large;                       $this->created = $created;                       $this->image = $image;               }
          public function setId ($id)    {                       $this->id = $id;               }
         public function getId ()    {                     return $this->id;             }
        public function setTitle ($title)    {                     $this->title = $title;    }
        public function getTitle ()    {                     return $this->title;    }
         public function setDescription ($description)    {                      $this->description = $description;    }
         public function getDescription ()    {                      return $this->description;    }
        public function setDescription_large ($description_large)    {                      $this->description_large = $description_large;    }
        public function getDescription_large ()    {                     return $this->description_large;    }
        public function setCreated ($created)    {                          $this->created = $created;    }
         public function getCreated ()    {                         return $this->created;    }
        public function setImage ($image)    {                     $this->image = $image;    }
        public function getImage ()    {                     return $this->image;    }}?>

Home.php

<?php $titel = "KFC Herenthtout - Home";include_once("classes/NewsDB.php");include_once("include/header.php"); 
$newsDb = new NewsDb();$news = $newsDb->getNews();?>
<div id="sub">    <?php echo $home; ?></div><div id="content"><table id="ctable"><tr><td id="left">        <h1>Het laatste nieuws</h1>              <table id="tblnews">        <tr>               <?php                       $counter = 1;                       if (count($news) == 0) {                               echo "Geen nieuws gevonden.";                       } else {                               for ($i=0; $i < count($news); $i++) {                                       $id = $news[$i]->getId();                                       $title = $news[$i]->getTitle();                                       $description = $news[$i]->getDescription();                                       $image = $news[$i]->getImage();                                       $date = $news[$i]->getDate();                                                        if($counter != 3){                                                 echo "<td class='newsitem'><img src='images/" . $image . "' alt='" . $title . "' width='150' />                                                            <h1><a href='newsdetail.php?id=" . $id . "'>" . $title . "</a><span class='newsdate'>" .                                         $date . "</span></h1><div>" . $description . "</div></td>";                                        }else{                                               echo "</tr><tr><td class='newsitem'><img src='images/" . $image . "' alt='" . $title . "' width='150' />                                                                       <h1><a href='newsdetail.php?id=" . $id . "'>" . $title . "</a><span class='newsdate'>" .                              $date . "</span></h1><div>" . $description . "</div></td>";                                                $counter = 0;                                       }                                      $counter++;                           }              }     ?>        </tr></table><p><a href='news.php'>>> Volledige nieuwsoverzicht</a></p></td> <!-- #left --><td id="right">

<?php include_once("include/footer.php"); ?>

aangepast door JorenWillems
code overzichtelijk
Link naar reactie
Delen op andere sites

Gast
Dit topic is nu gesloten voor nieuwe reacties.
×
×
  • Nieuwe aanmaken...

Belangrijke informatie

We hebben cookies geplaatst op je toestel om deze website voor jou beter te kunnen maken. Je kunt de cookie instellingen aanpassen, anders gaan we er van uit dat het goed is om verder te gaan.