I've decided to simply things by getting rid of the class.mysql.php
portion and just using mysqli functions within each class.
Under class.members.php I've created the constructor to initialize the
database vars.
class members {
var $iMemberID;
var $iProfileID;
var $_iMemberID;
var $_iProfileID;
var $mysqli;
var $query;
function members($dbServer, $dbUser, $dbPassword, $dbDSN){
$this->_dbServer = $dbServer;
$this->_dbUser = $dbUser;
$this->_dbPassword = $dbPassword;
$this->_dbDSN = $dbDSN;
}
[...]
}
Under class.mail.php I've extended members():
class memberMail extends members {
var $iMailID;
function memberMail(){
parent::members();
}
function fnGetMailCount() {
$sql = "
SELECT iMessageID
FROM tblEmail
WHERE iToMemberID = ". $this->getMemberID();
$mysqli = new mysqli($this->_dbServer, $this->_dbUser,
$this->_dbPassword, $this->_dbDSN);
$query = $mysqli->query($sql);
return $query->num_rows;
}
function fnGetMail() {
$sql = "
SELECT *
FROM tblEmail
WHERE iToMemberID = ". $this->getMemberID() ."
Order by dtEmailDate Desc";
$mysqli = new mysqli($this->_dbServer, $this->_dbUser,
$this->_dbPassword, $this->_dbDSN);
$query = $mysqli->query($sql);
return $query->fetch_object();
//return $query->num_rows;
//return $query->fetch_assoc();
}
[....]
}
If I do a page to get the mail for a user, I run into an issue:
<?
require_once("../../classes/class.members.php");
require_once("../../classes/class.mail.php");
session_start();
require_once("../../_global.php");
$objMember = new members(); //intialize member class
$objMail = new memberMail(); //initialize memberMail class
$objMail->members($aSiteSettings["sDBServer"],
$aSiteSettings["sDBLogin"], $aSiteSettings["sDBPassword"],
$aSiteSettings["sDSN"]);
$objMail->setMemberID($_SESSION["iMemberID"]);
$iMailCount = $objMail->fnGetMailCount();
while($rows=$objMail->fnGetMail()){
print_r($rows->sTitle);
}
//echo $result;
/*
$sql = "
SELECT *
FROM tblEmail
WHERE iToMemberID = ". $_SESSION["iMemberID"] ."
Order by dtEmailDate Desc";
$mysqli = new mysqli($aSiteSettings["sDBServer"],
$aSiteSettings["sDBLogin"], $aSiteSettings["sDBPassword"],
$aSiteSettings["sDSN"]);
$query = $mysqli->query($sql);
while($rows = $query->fetch_object()){
print_r($rows->sTitle);
}
$mysqli->close;
*/
?>
The call to the class members and memberMail creates an infite loop;
however, if I bypass the classes and do the mysqli functions directly
on the page, I get the right output. There is only one record in the
database; fnGetMailCount() produces one record and fnGetMail() using
'return $query->num_rows' produces one record. I'm assuming there's
something with my while loop, but I've used this method for other
query output without issue.
One other note, I've also tested by removing all session variables and
hard coding values instead and received the same results.
I apologize if these are basic questions, but while I'm learning, I
would prefer to learn properly instead of coding a bunch of junk just
for the sake of getting it done quickly.
--- In [email protected], "Mike Franks" <[EMAIL PROTECTED]> wrote:
>
> On 7/13/2005, "balthork" <[EMAIL PROTECTED]> wrote:
>
> >
> >
> >
> Unfortunately, it is not generating any output. What gets me is the
> query works the very first time the page loads. It's when the page
is
> refreshed that I get an error. Would this have anything to do with
> how the functions are being called or sessions?
> >
> >
> >
> >
>
> Certainly sounds like a problem with sessions. Like maybe you're
> initializing something the first time, but forgetting to put it into
> session. Then, on second time, you're expecting it to be in session
but
> it isn't.
>
> Try var_dump('yourObjectName') and print_r($_SESSION) at key points
in
> your code. The output may be difficult to read on your page, but
should
> be nicely formatted if you view the source for the page in Notepad.
>
> Mike
Community email addresses:
Post message: [email protected]
Subscribe: [EMAIL PROTECTED]
Unsubscribe: [EMAIL PROTECTED]
List owner: [EMAIL PROTECTED]
Shortcut URL to this page:
http://groups.yahoo.com/group/php-list
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/php-list/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/