pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

PHP pastebin - collaborative debugging tool View Help


Posted by Stig on Sat 22 Nov 08:50
report abuse | download | new post

  1. <?php
  2.  
  3. class myClass {
  4.  
  5.  
  6.         var $link, $result;
  7.  
  8.         function db_connect($server, $user, $pass, $database) { // ->db_connect("localhost", "user", "pass", "db");
  9.  
  10.                 if(!$this->link = mysql_connect($server, $user, $pass)) {
  11.                         $this->error("Could not connect: " . mysql_error());
  12.                 }
  13.  
  14.                 if(!mysql_select_db($database, $this->link)) {
  15.                         $this->error("Could not select database: " . mysql_error());
  16.                 }
  17.                
  18.                 return true;
  19.         }
  20.  
  21.         function error($error) {
  22.  
  23.                 $string_error = date("d/m/Y - H:i:s ") . " (" . $_SERVER['REMOTE_ADDR'] . ")\n" . $error . "\n\n";
  24.                 $file = "errors.txt";
  25.                 $file = fopen($file, 'a') or die("Fejl, hændelsen kunne ikke logges!");
  26.                 fwrite($file, $string_error);
  27.                 die("Der er opstået en uventet fejl. Hændelsen er blevet logget og Administrator vil blive informeret.");
  28.         }
  29.  
  30.  
  31.         function getRows() { // while($row = $con->getRows()) { echo $row['id']; }
  32.                 return mysql_fetch_assoc($this->result);
  33.         }
  34.  
  35.         function query($sql) {
  36.  
  37.                 if(!$this->result = mysql_query($sql, $this->link)) {
  38.                         $this->error("mysql_query error: " . mysql_error());
  39.                 }
  40.         }
  41.  
  42.         function getQuery($table, $what="*", $end="") { // ->getQuery("info", "*", "ORDER BY navn ASC");
  43.  
  44.                 $sql = "SELECT $what FROM $table $end";
  45.                 $this->query($sql);
  46.         }
  47.  
  48.         function cntRows() { // echo ->cntRows();
  49.                 return mysql_num_rows($this->result);
  50.         }
  51.  
  52.         function insQuery($table, $column_data) { // ->insert("info", "navn='Navn', adresse='Adresse'");
  53.  
  54.                 $sql = "INSERT INTO $table SET $column_data";
  55.                 $this->query($sql);
  56.         }
  57.  
  58.         function delQuery($table, $where, $is) { // ->delete("info", "id", "1");
  59.  
  60.                 $sql = "DELETE FROM $table WHERE $where = '$is'";
  61.                 $this->query($sql);
  62.         }
  63.  
  64.         function updQuery($table, $what, $with, $where, $is) { // ->updQuery("info", "navn", "Navn", "id", "1");
  65.  
  66.                 $sql = "UPDATE $table SET $what = '$with' WHERE $where = '$is'";
  67.                 $this->query($sql);
  68.         }
  69.  
  70. }
  71. ?>

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me so that I can delete my post