The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Why are no errors thrown, but no SQL results shown?
masonh928
post Oct 5 2015, 02:44 PM
Post #1


Serious Coder
*****

Group: Members
Posts: 253
Joined: 17-August 13
From: Indiana
Member No.: 19,570



Ever since I added the reply class, none of the posts nor replies have been displayed.

Reply.class.php
CODE

<?php

error_reporting(E_ALL | E_STRICT);

class Reply{

public $Replier;
public $Reply;
public $ReplyDate;
public $ReplyDate2;
public $IDtoReply;

public $Connect;

public function retrieveReplies($IDtoReply, $Connect){

$this->IDtoReply = $IDtoReply;
$this->Connect = $Connect;

$Query = $this->Connect->prepare("SELECT * FROM Replies ORDER BY Date DESC");
$Query->execute() or die($Query->ErrorInfo());

$Results = $Query->fetchAll();

foreach($Results as $Rows){

$this->Replier = $Rows['Replier'];
$this->Reply = $Rows['Reply'];
$this->ReplyDate = betterDate($Rows['Date']);
$this->ReplyDate2 = ageDate($Rows['Date']);

$Reply = <<<Reply
<p style="text-indent:50px;"><a>{$this->Replier}:</a> {$this->Reply} <i>{$this->ReplyDate} ({$this->ReplyDate2})</i></p>
Reply;
return $Reply;
}

}

}

?>


Board.class.php

CODE

<?php
require_once($_SERVER['DOCUMENT_ROOT'] . "/Scripts/PHP/Library.php");

require_once("Reply.class.php");

error_reporting(E_ALL | E_STRICT);

Class Board extends Reply{

public $Connect;

public $Poster;
public $PostTo;
public $Post;
public $PostedDate;

public $Poster2;
public $PostTo2;
public $Post2;

public $Rows;

public function __construct($PostToID){


try{

$this->Connect = new pdo("mysql:host=mysql.hostinger.co.uk;dbname=u645944288_all", "u645944288_mason", "mason671");
$this->Connect->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING );

}catch(PDOException $ex){

    die(json_encode(array('outcome' => false, 'message' => 'Unable to connect')));
}

$Query = $this->Connect->prepare("SELECT Username FROM Board WHERE ID = :ID");
$Query->bindValue(":ID", $PostToID);
$Query->execute() or die($Query->ErrorInfo());

$Row = $Query->fetch();

return $this->PostTo = $Row['Username'];
}

public function DisplayPosts(){

$Query = $this->Connect->prepare("SELECT * FROM Board WHERE Username = :Username ORDER BY Date DESC");
$Query->bindValue(":Username", $this->PostTo);
$Query->execute() or die($Query->ErrorInfo());
$Results = $Query->fetchAll();
foreach($Results as $Rows){
$Class = ($Rows['Poster'] == $this->PostTo) ? "PostSelf" : "PostOther";
$Poster = $Rows['Poster'];
$Date1 = betterDate($Rows['Date']);
$Date2 = AgeDate($Rows['Date']);
$ID = $Rows['ID'];
$Reply = Reply::retrieveReplies($ID, $this->Connect);

$Post = $Rows['Post'];
echo <<<Post
<section class="{$Class}">
<h3>{$Poster}</h3>
<h6>{$Date1} ({$Date2})</h6>
<p>{$Post}</p>
<hr>
<div>{$Reply}</div>
</section>
<br/><hr>
Post;
}

}

}

?>


No errors at all, not even a notice or such. I have setAttribute...
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Oct 5 2015, 03:46 PM
Post #2


Programming Fanatic
********

Group: Members
Posts: 1,981
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



Nothing jumps out at me. The only thing I think might cause problems is your use of return in the foreach section of Reply class. Maybe you should treat $Reply as an array and then use the implode command to write the array to the page.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 28th March 2024 - 06:33 PM