hi there,
i am using class that i found somewhere on the net.
it doesnt return the results the way it should.
could any1 look at it, and spot the error.
and, of course improve it. that will be great.
thank you,
rutin,
p.s.
if needed i could post a sample function that makes the problem.
<?php
// Check for MySQL Support, class starts
if (!function_exists('mysql_connect')) die('Sorry, your server does not have support for MySQL');
class mysql {
var $host = '';
var $user = '';
var $pass = '';
var $database = '';
var $linkid;
var $result;
var $record = array();
var $rows;
function config($host, $user, $pass, $database)
{
$this->host = $host;
$this->user = $user;
$this->pass = $pass;
$this->database = $database;
return true;
}
function connect()
{
$this->linkid = mysql_connect($this->host, $this->user, $this->pass) or $this->error(mysql_error());
return $this->linkid;
}
function selectdatabase()
{
mysql_select_db($this->database) or $this->error(mysql_error());
return true;
}
function query($sql)
{
$this->result = mysql_query($sql) or $this->error(mysql_error());
return $this->result;
}
function fetcharray($result)
{
$this->record = mysql_fetch_array($result);
$this->clean;
return $this->record ;
}
function fetchassoc()
{
$this->record = mysql_fetch_assoc($this->result);
$this->clean;
return $this->record;
}
function fetchrow()
{
$this->record = mysql_fetch_row($this->result);
$this->clean;
return $this->record;
}
function clean()
{
foreach($this->record as $key => $val) {
$this->record[$key] = stripslashes($val);
}
return $this->record;
}
function totalrows($result)
{
$this->rows = mysql_num_rows($this->result);
return $this->rows;
}
function close()
{
mysql_close($this->linkid);
return true;
}
function free($result)
{
mysql_free_result($result);
}
function error($text)
{
echo '<div align="center">';
echo '<h2>mysql error</h2>';
echo '<hr width="40%">';
echo $text;
echo '</div>';
exit;
}
function mysql()
{
$this->connect();
$this->selectdatabase();
}
} //end class
$database = new mysql();
?>