Code: Alles auswählen
<?php
if (!defined('IN_GREATBOOK'))
{
die('Hacking attempt');
}
class Database
{
var $connection_id;
var $resource_id;
function Database($sql_server, $sql_user, $sql_password, $sql_database)
{
$this->server = trim($sql_server);
$this->user = trim($sql_user);
$this->password = trim($sql_password);
$this->database = trim($sql_database);
$this->connection_id = mysql_connect($this->server, $this->user, $this->password);
if ($this->connection_id)
{
$this->connection_id = mysql_select_db($sql_database);
if (!$this->connection_id)
{
return false;
}
else
{
return $this->connection_id;
}
}
else
{
return false;
}
}
function sql_query($sql)
{
$this->resource_id = mysql_query($sql);
if (!$this->resource_id)
{
return false;
}
else
{
return $this->resource_id;
}
}
function sql_fetchassoc($result)
{
$this->resource_id = mysql_fetch_assoc($result);
if (!$this->resource_id)
{
return false;
}
else
{
return $this->resource_id;
}
}
function sql_error($error, $error_descripton, $file, $line, $sql)
{
die('GreatBook: <b>' . $error . '</b>
<br />
<br />
' . $error_descripton . '
<br />
<br />
<b><u>DEBUG MODE</u></b>
<br />
<br />
SQL Error: ' . mysql_errno() . ' ' . mysql_error() . '
<br />
<br />
' . $sql . '
<br />
<br />
Linie: ' . $line . '
<br />
File: ' . basename($file)
);
}
} // end class
?>
Code: Alles auswählen
mysql_errno() und mysql_error()
Code: Alles auswählen
mysql_errno($this->connection_id);
und bei der sql_query function funktioniert:
Code: Alles auswählen
mysql_query($sql);
Code: Alles auswählen
mysql_query($sql, $this->connection_id);