PHP5 database code issue
Posted: Wed Jun 06, 2007 2:09 pm
I'm new to the whole OOP scene, and I was trying to write some database code. Unfortunately, the following code refuses to display any data, just two breaks (the number of the records in that table). When I do a print_r() on $results, it displays all of the data returned by the query, but as soon as I do the simple echo, it shows nothing at all!
from mssql.class.php:
From the actual script (database.php):
I would sincerely appreciate any help you could offer.
from mssql.class.php:
Code: Select all
//query the database
function query($query) {
try {
$this->result = @mssql_query($query, $this->linkId);
if (! $this->result)
throw new Exception("The query failed. Check your syntax.");
}
catch (Exception $e) {
die($e->getMessage());
}
return $this->result;
}
//put the results into a usable array
function fetchArray() {
$array = @mssql_fetch_assoc($this->result);
return $array;
}Code: Select all
//run the query
$sqlDb->query("SELECT * NAMES");
while ($results = $sqlDb->fetchArray()) {
//print_r($results);
echo ("$results->NAME <br />");
}