I've got a coding problem here that I could use some help with.
Here's my db class (the config.php only has db connection info):
*************** *************** *************** *************** ********
<?php
// db_handler.inc
require_once("c onfig.php");
class db {
var $mySQLresult;
function db() {
$this->dbConn = mysql_connect(D B_HOST, DB_USER, DB_PW);
mysql_select_db (DB_NAME, $this -dbConn) or
die(mysql_error ());
}
function db_Select($tabl es, $columns="'*'", $conditions="") {
$sql = "SELECT ".$columns. " FROM ".$tables." ".$conditio ns;
$row = mysql_query($sq l, $this -dbConn) or
die(mysql_error ());
$this->mySQLresult = $row;
}
function db_Fetch($type = MYSQL_BOTH) { //MYSQL_ASSOC
$row = mysql_fetch_arr ay($this -mySQLresult, $type) or
die(mysql_error ());
if ($row) {
return $row;
} else {
return FALSE;
}
}
}
?>
*************** *************** *************** *************** ********
Here's the code I'm executing:
*************** *************** *************** *************** ********
<?php
require_once("i ncludes/db_handler.inc" );
require_once("i ncludes/config.php");
echo "Hit 1<br />";
$sql = new db;
$result = $sql -db_Select(DB_TA BLE_ORG_INFO);
while ($row = $sql -db_Fetch()) {
$organization_d isclaimer =
$row['organization_d isclaimer'];
}
echo "Hit 2<br />";
?>
*************** *************** *************** *************** ********
For some reason, the while loop is halting execution and won't display
"echo "Hit 2<br />";". The script just stops executing.
Any idea's why?
I'm using php5
Here's my db class (the config.php only has db connection info):
*************** *************** *************** *************** ********
<?php
// db_handler.inc
require_once("c onfig.php");
class db {
var $mySQLresult;
function db() {
$this->dbConn = mysql_connect(D B_HOST, DB_USER, DB_PW);
mysql_select_db (DB_NAME, $this -dbConn) or
die(mysql_error ());
}
function db_Select($tabl es, $columns="'*'", $conditions="") {
$sql = "SELECT ".$columns. " FROM ".$tables." ".$conditio ns;
$row = mysql_query($sq l, $this -dbConn) or
die(mysql_error ());
$this->mySQLresult = $row;
}
function db_Fetch($type = MYSQL_BOTH) { //MYSQL_ASSOC
$row = mysql_fetch_arr ay($this -mySQLresult, $type) or
die(mysql_error ());
if ($row) {
return $row;
} else {
return FALSE;
}
}
}
?>
*************** *************** *************** *************** ********
Here's the code I'm executing:
*************** *************** *************** *************** ********
<?php
require_once("i ncludes/db_handler.inc" );
require_once("i ncludes/config.php");
echo "Hit 1<br />";
$sql = new db;
$result = $sql -db_Select(DB_TA BLE_ORG_INFO);
while ($row = $sql -db_Fetch()) {
$organization_d isclaimer =
$row['organization_d isclaimer'];
}
echo "Hit 2<br />";
?>
*************** *************** *************** *************** ********
For some reason, the while loop is halting execution and won't display
"echo "Hit 2<br />";". The script just stops executing.
Any idea's why?
I'm using php5
Comment