1 Replies - 610 Views - Last Post: 20 November 2012 - 10:43 AM Rate Topic: -----

#1 skymonkier   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 107
  • Joined: 14-July 12

Rows from DB not displaying, nor error.

Posted 20 November 2012 - 10:38 AM

I'm trying to make a simple news/update system, and I recently tried to add a little more functionality to it (thanks, Atli!). However, as it stands, it doesn't display any rows from my DB. It also doesn't display any error, so I'm at a complete loss for what it could be.

displaynews.php
<?php			
	try {
		$countRows = $conn->query("SELECT COUNT(*) FROM ss_news");
		
		if (0 < (int)$countRows->fetchColumn()) {
		    
				$selectRows = $conn->query("SELECT title, author, news, date FROM ss_news ORDER BY id DESC LIMIT 5");
			
				foreach ($selectRows as $row) {
					$title = htmlentities($row["title"], ENT_QUOTS, "UTF-8");
					$news = htmlentities($row["news"], ENT_QUOTES, "UTF-8");
					$date = htmlentities($row["date"], ENT_QUOTES, "UTF-8");
					$author = htmlentities($row["author"], ENT_QUOTES, "UTF-8");
		    
					$news = preg_replace('/(\r?\n){2,}/', "<br /><br />", $news);
					
					echo <<<HTML <div class="post"><img src="css/images/testpimg.png" class="ico"><h1 class="p-title"> {$title} </h1><p class="p-text"> {$news}</p><p class="p-info"> {$date} &dash; <span class="name"> {$author} </span> </p></div>
	HTML;
				}
  		} else {
    		echo "No rows returned.";
 		 }
		
	} catch(PDOException $e) {
		echo "<p>Sorry, there was an error;   " . $e->getMessage() . ".</p>"; //Print out the exception
	}
?>



Is This A Good Question/Topic? 0
  • +

Replies To: Rows from DB not displaying, nor error.

#2 Dormilich   User is offline

  • 痛覚残留
  • member icon

Reputation: 4288
  • View blog
  • Posts: 13,594
  • Joined: 08-June 10

Re: Rows from DB not displaying, nor error.

Posted 20 November 2012 - 10:43 AM

line #18, HEREDOC closing delimiter must start at the beginning of the line (no whitespace or other characters before it).

line #17, HEREDOC opening delimiter must be followed by a newline/line break
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1