The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Display MySQL data
#1
Hi, I am new to user spice and just started working on PhP MYSQL as i'm building a blog system. Sorry for asking stupid question. How can i fetch all data from mysql and display it? Here is the error code:

<pre>
Code:
Fatal error: Uncaught Error: Call to a member function query() on null
</pre>
<?php
try {

$stmt = $db->query('SELECT postID, postTitle, postDesc, postDate FROM blog_posts ORDER BY postID DESC');
while($row = $stmt->fetch()){

echo '<div>';
echo '<h1>.']'.$row['postTitle'].'</h1>';
echo '<p>Posted on '.date('jS M Y H:iConfused', strtotime($row['postDate'])).'</p>';
echo '<p>'.$row['postDesc'].'</p>';
echo '<p>.']Read More</p>';
echo '</div>';

}

}
?>
  Reply


Messages In This Thread
Display MySQL data - by kang08 - 08-07-2016, 05:21 AM
Display MySQL data - by mudmin - 08-11-2016, 09:42 PM
Display MySQL data - by kang08 - 08-12-2016, 10:19 AM
Display MySQL data - by mudmin - 08-12-2016, 11:25 PM
Display MySQL data - by kang08 - 08-13-2016, 07:45 AM
Display MySQL data - by mudmin - 08-14-2016, 12:01 PM
Display MySQL data - by mudmin - 08-18-2016, 02:16 PM
Display MySQL data - by picassoo - 08-22-2016, 10:10 AM
Display MySQL data - by mudmin - 08-22-2016, 01:32 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)