Gebrauchtbörse
host = "localhost"; $this->user = "berr"; $this->pass = "07be77rr"; $this->dbase = "berr"; $this->conn = mysql_connect($this->host,$this->user,$this->pass); if($this->conn){ $this->select_db($this->dbase); return $this->conn; } else { die ("
Fehler beim Verbinden
"); } } function select_db($db){ if (!mysql_select_db($db,$this->conn)){ echo "
Fehler beim Auswählen der DB...
"; } } function query($sql){ if (!$this->result = mysql_query($sql,$this->conn)){ die ('
Fehler beim Senden der Abfrage: ' . $sql . '
'.mysql_error()); } else { return $this->result; } } function rows(){ $this->rows = mysql_num_rows($this->result); return $this->rows; } function insert_id(){ $this->id = mysql_insert_id(); return $this->id; } function count_records($table,$abfrage=""){ $sql = "select count(*) as num from $table "; if ($abfrage != "") $sql .= "WHERE $abfrage"; if (!$this->result = mysql_query($sql,$this->conn)){ die ("
Fehler beim Senden der Abfrage...
".mysql_error()); } else { $daten = mysql_fetch_array($this->result); $this->num = $daten['num']; return $daten['num']; } } function sql($sql,$temp){ if (!$this->result = mysql_query($sql,$this->conn)){ die ("
Fehler beim Senden der Abfrage...
".mysql_error()); } else { if ($temp == "id"){ $this->temp = mysql_insert_id(); } elseif ($temp == "rows"){ $this->temp = mysql_num_rows($this->result); } elseif ($temp == "affected"){ $this->temp = mysql_affected_rows(); } return $this->result; } } } ?>