Guest User

MYSQL fehler

a guest
Nov 1st, 2014
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1. <?php
  2.  
  3. namespace Revolution;
  4. if(!defined('IN_INDEX')) { die('Sorry, you cannot access this file.'); }
  5. class forms implements iForms
  6. {
  7.  
  8. public $error;
  9.  
  10. final public function setData()
  11. {
  12. global $engine;
  13. foreach($_POST as $key => $value)
  14. {
  15. if($value != null)
  16. {
  17. $this->$key = $engine->secure($value);
  18. }
  19. else
  20. {
  21. $this->error = 'Please fill in all fields';
  22. return;
  23. }
  24. }
  25.  
  26. }
  27.  
  28. final public function unsetData()
  29. {
  30. global $template;
  31. foreach($this as $key => $value)
  32. {
  33. unset($this->$key);
  34. }
  35. }
  36.  
  37. final public function writeData($key)
  38. {
  39. global $template;
  40. echo $this->$key;
  41. }
  42.  
  43. final public function outputError()
  44. {
  45. global $template;
  46. if(isset($this->error))
  47. {
  48. echo "<div id='message'> " . $this->error . " </div>";
  49. }
  50. }
  51.  
  52. /* Manage different pages */
  53.  
  54. final public function getPageNews()
  55. {
  56. global $template, $engine;
  57.  
  58. if(!isset($_GET['id']) || !is_numeric($_GET['id']))
  59. {
  60. $_GET['id'] = 1;
  61. }
  62. $result = mysql_query("SELECT title, id FROM cms_news WHERE id != '" . $engine->secure($_GET['id']) . "' ORDER BY id DESC");
  63.  
  64. while($news1 = mysql_fetch_array($result))
  65. {
  66. $template->setParams('newsList', '&laquo; <a href="index.php?url=news&id='.$news1["id"].'">' . $news1['title'] . '</a><br/>');
  67. }
  68.  
  69. $news = $engine->fetch_assoc("SELECT id, title, shortstory, longstory, author, published FROM cms_news WHERE id = '" . $engine->secure($_GET['id']) . "' LIMIT 1");
  70. $template->setParams('newsID', $news['id']);
  71. $template->setParams('newsTitle', $news['title']);
  72. $template->setParams('newsContent', $news['longstory']);
  73. $template->setParams('newsAuthor', $news['author']);
  74. $template->setParams('newsDate', date("d-m-y", $news['published']));
  75.  
  76. unset($result);
  77. unset($news1);
  78. unset($news);
  79. }
  80.  
  81. final public function getPageHome()
  82. {
  83. global $template, $engine;
  84. $a = 1;
  85. $data = mysql_query("SELECT title, id, published, shortstory, image FROM cms_news ORDER BY id DESC LIMIT 5");
  86.  
  87. while($news = mysql_fetch_assoc ($data, MYSQL_ASSOC))
  88. {
  89. $template->setParams('newsTitle-' . $a, $news['title']);
  90. $template->setParams('newsID-' . $a, $news['id']);
  91. $template->setParams('newsDate-' . $a, date("d-m-y", $news['published']));
  92. $template->setParams('newsCaption-' . $a, $news['shortstory']);
  93. $template->setParams('newsIMG-' . $a, $news['image']);
  94. $a++;
  95. }
  96.  
  97. unset($news);
  98. unset($data);
  99. }
  100.  
  101. }
  102.  
  103. ?>
Advertisement
Add Comment
Please, Sign In to add comment