Fehler, den ich nicht finde...

tittli

Erfahrenes Mitglied
Hallo

Habe folgendes Script aus einem Buch...es geht dabei um eine Abstimmung, wobei ich nur das Login-System brauche. Irgendwie will das ganze nicht funktionieren.

Fehlermeldungen:

Warning: Supplied argument is not a valid MySQL-Link resource in c:\www\mysqldb.php on line 65

Warning: Supplied argument is not a valid MySQL-Link resource in c:\www\mysqldb.php on line 65


Das kommt wenn ich einen Benutzer anlegen will...
Beim Anmelden von bereits vorhandenen Benutzern kommt folgende Fehlermeldung:

Fatal error: Cannot redeclare class mysql_db in c:\www\mysqldb.php on line 16


Die Datei mysqldb.php sieht folgendermassen aus:

PHP:
class mysql_db {
	var $link = false;
	var $resid = false;
	var $doerror = false;
	var $host = "host";
	var $user = "user";
	var $passwd = "";
	var $tables = "votum";

	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])."&nbsp;</td>");
    echo("</tr>\n");
  }
  echo ("</table>");
}


function set_doerror($boolvalue)
{
  $this->doerror = $boolvalue;
}


function mysql_db()
// Construktor
{
  $this->connect();
}

}
	
	
$db = new mysql_db;
	
?>


In dieser Datei geht es um die Deklaration von einigen Methoden, die beim System gebraucht werden. Wer sieht den Fehler?

Danke
 
hallo

hat denn hier niemand lust, mein script durchzusehen?...ja ich weiss es ist relativ viel...aber bitte, es ist für mich relativ wichtig, dass das ganze funktioniert...

danke

gruss
 
Zurück