exitboy
Erfahrenes Mitglied
Fatal error: Call to a member function on a non-object in /srv/www/htdocs/web1/html/tiptaptor/admin.php on line 12
--> WHY THIS? Könnt Ihr mir da weiterhelfen? Ist doch alles drin ...
start.php
mysqldb.php
--> WHY THIS? Könnt Ihr mir da weiterhelfen? Ist doch alles drin ...
start.php
Code:
<?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Title</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<?php
include("mysqldb.php");
$db->echoquery("select * from login");
?>
</body>
</html>
mysqldb.php
Code:
<?php
// MySQL Klassendefinition
//
// Methoden:
// set_doerror($boolvalue))
// int connect()
// int query($sql)
// echoerror()
// array rowarray()
// echoquery($sql)
class mysql_db {
var $link = false;
var $resid = false;
var $doerror = false;
var $host = "localhost";
var $user = "webuser";
var $passwd = "test";
var $tables = "u_web";
function set_doerror($boolvalue)
{
$this->doerror = $boolvalue;
}
function connect()
// Verbindet zur Datenbank
{
$temp = @mysql_connect
($this->host, $this->user, $this->passwd);
if (!$temp)
{
$this->echoerror();
return false;
}
$this->link = $temp;
$temp = @mysql_select_db($this->tables, $temp);
if (!$temp)
{
$this->echoerror();
return false;
}
return $this->link;
}
function query($sql)
// Sendet eine Anfrage an die Datenbank
{
if (!$this->link)
{
if ($this->doerror)
{
echo ("<b>Nicht verbunden.</b><br>");
return false;
}
}
if ($this->resid) @mysql_free_result($this->resid);
$result = mysql_query($sql, $this->link);
if (!$result) $this->echoerror();
$this->resid = $result;
return $result;
}
function echoerror()
// erzeugt eine Fehlerausschrift
// wenn $doerror=TRUE
{
if (!$this->doerror) return;
if (!mysql_errno()) return;
echo ("<font color=\"red\"><b>" . mysql_errno());
echo (": ". mysql_error() ." </b></font><br>");
}
function data()
// liefert einen Datensatz
{
if (!$this->link)
{
if ($this->doerror)
echo ("<b>Nicht verbunden!</b><br>");
return false;
}
if (!$this->resid)
{
if ($this->doerror)
echo ("<b>Keine Abfrage!</b><br>");
return false;
}
$result = mysql_fetch_array($this->resid, MYSQL_BOTH);
$this->echoerror();
return $result;
}
function echoquery($sql)
//Fragt die Datenbank ab und stellt die Abfrage dar
{
$this->query($sql);
echo("<table border cellpadding=\"3\"><tr>");
$index = 0;
echo("<th>record</th>");
while ($field = mysql_fetch_field($this->resid))
echo("<th>$field->name</th>");
echo ("</tr>\n");
$rec=0;
while ($row = $this->data())
{
$rec++;
echo("<tr><td>$rec</td>");
for ($i=0; $i<mysql_num_fields($this->resid); $i++)
echo("<td>".htmlentities($row[$i])." </td>");
echo("</tr>\n");
}
echo ("</table>");
}
/*function set_doerror($boolvalue)
{
$this->doerror = $boolvalue;
}
*/
function mysql_db()
// Construktor
{
$this->connect();
}
}
$db = new mysql_db;
?>