Witam!

Znalazłem na youtube filmik jak zrobić własnego CMS'a i robię dokładnie tak jak jest na filmikach. Udało mi się zrobić by wyświetlane były wszystkie posty z bazy danych, lecz gdy klikam by pokazało konkretnego posta pokazuje błąd taki jak przy nieistniejącym poście.

kod z index.php
  1. <?php
  2. include '_class/cms_class.php';
  3.  
  4. $obj = new moderncms();
  5.  
  6. $obj->host = 'localhost';
  7. $obj->username = 'root';
  8. $obj->password = '';
  9. $obj->db = 'moderncms';
  10.  
  11. $obj->connect();
  12.  
  13. ?>


kod do wyświetlenia postów:
  1. <?php
  2. if(isset($_GET['id'])):
  3. $obj->get_content($_GET['id']);
  4. else:
  5. $obj->get_content();
  6. endif;
  7. ?>


podłączony plik .php:
  1. <?php
  2.  
  3. class modernCMS {
  4.  
  5. var $host;
  6. var $username;
  7. var $password;
  8. var $db;
  9.  
  10. function connect() {
  11. $con = mysql_connect($this->host, $this->username, $this->password) or die(mysql_error());
  12. mysql_select_db($this->db, $con) or die(mysql_error());
  13. }
  14.  
  15. function get_content($id = ''){
  16.  
  17. if($id != ""):
  18. $sql = "SELECT * FROM cms_content WHERE id = 'id'";
  19. else:
  20. $sql = "SELECT * FROM cms_content ORDER BY id DESC";
  21. endif;
  22.  
  23. $res = mysql_query($sql) or die(mysql_error());
  24.  
  25. if(mysql_num_rows($res) != 0):
  26. while($row = mysql_fetch_assoc($res)){
  27. echo '<article><h2><a href="index.php?id=' . $row['id'] . '">' . $row['title'] . '</a></h2>';
  28. echo '<p id="post">' . $row['body'] . '</p>';
  29. echo '<p id="date">Posted by TasAroV on ' . $row['date'] . '</p></article>';
  30. }
  31. else:
  32. echo '<p>We are really very sorry, but this page couldn\'t be loaded because of one of the folowing reasons:</p>';
  33. echo '<ul><li>there is one of the files missing,</li><li>there is no post with that id,</li><li>server fell asleep,</li><li>servers went over to the dark side.</li></ul>';
  34. endif;
  35. }
  36.  
  37. }//Ends our class
  38.  
  39. ?>


Wszystko jest uruchamiane na moim komputerze przy użyciu WAMPSERVER: Apache 2.2.21, PHP 5.3.10 i MySQL 5.5.20. Za wszelką pomoc będę bardzo wdzięczny smile.gif