You are here: While Loop Problem « PHP Programming Language « IT news, forums, messages
While Loop Problem

Posted by Jesse Burns aka jburns131 on 11/21/07 05:28

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("config.php");

class db {

var $mySQLresult;

function db() {

$this->dbConn = mysql_connect(DB_HOST, DB_USER, DB_PW);
mysql_select_db(DB_NAME, $this -> dbConn) or
die(mysql_error());
}

function db_Select($tables, $columns="'*'", $conditions="") {

$sql = "SELECT ".$columns." FROM ".$tables." ".$conditions;
$row = mysql_query($sql, $this -> dbConn) or
die(mysql_error());
$this->mySQLresult = $row;
}

function db_Fetch($type = MYSQL_BOTH) { //MYSQL_ASSOC
$row = mysql_fetch_array($this -> mySQLresult, $type) or
die(mysql_error());
if ($row) {
return $row;
} else {
return FALSE;
}
}
}

?>

********************************************************************

Here's the code I'm executing:

********************************************************************

<?php

require_once("includes/db_handler.inc");
require_once("includes/config.php");

echo "Hit 1<br />";

$sql = new db;
$result = $sql -> db_Select(DB_TABLE_ORG_INFO);
while ($row = $sql -> db_Fetch()) {

$organization_disclaimer =
$row['organization_disclaimer'];
}

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация