Ver Mensaje Individual
  #7 (permalink)  
Antiguo 11/09/2014, 08:41
abel_dg
 
Fecha de Ingreso: diciembre-2008
Mensajes: 10
Antigüedad: 15 años, 5 meses
Puntos: 0
Respuesta: Problema con script de encuesta

Código PHP:
Ver original
  1. class polldb_sql {
  2.  
  3.     var $conn_id;
  4.     var $result;
  5.     var $record;
  6.     var $db;
  7.     var $port;
  8.     var $query_count;
  9.  
  10.     function polldb_sql() {
  11.         global $POLLDB;
  12.         $this->query_count=0;
  13.         $this->db = $POLLDB;
  14.         if(ereg(":",$this->db['host'])) {
  15.             list($host,$port) = explode(":",$this->db['host']);
  16.             $this->port = $port;
  17.         } else {
  18.             $this->port = 3306;
  19.         }
  20.     }
  21.  
  22.     function connect() {
  23.         $this->conn_id = mysql_connect($this->db['host'].":".$this->port,$this->db['user'],$this->db['pass']);
  24.         if ($this->conn_id == 0) {
  25.             $this->sql_error("Connection Error");
  26.         }
  27.         if (!mysql_select_db($this->db['dbName'], $this->conn_id)) {
  28.             $this->sql_error("Database Error");
  29.         }
  30.         return $this->conn_id;
  31.     }
  32.  
  33.     function query($query_string) {
  34.         $this->result = mysql_query($query_string,$this->conn_id);
  35.         $this->query_count++;
  36.         if (!$this->result) {
  37.             $this->sql_error("Query Error");
  38.         }
  39.         return $this->result;
  40.     }
  41.  
  42.     function fetch_array($query_id) {
  43.         $this->record = mysql_fetch_array($query_id,MYSQL_ASSOC);
  44.         return $this->record;
  45.     }
  46.  
  47.     function num_rows($query_id) {
  48.         return ($query_id) ? mysql_num_rows($query_id) : 0;
  49.     }
  50.  
  51.     function num_fields($query_id) {
  52.         return ($query_id) ? mysql_num_fields($query_id) : 0;
  53.     }
  54.  
  55.     function free_result($query_id) {
  56.         return mysql_free_result($query_id);
  57.     }
  58.  
  59.     function affected_rows() {
  60.         return mysql_affected_rows($this->conn_id);
  61.     }
  62.  
  63.     function close_db() {
  64.         if($this->conn_id) {
  65.             return mysql_close($this->conn_id);
  66.         } else {
  67.             return false;
  68.         }
  69.     }
  70.  
  71.     function sql_error($message) {
  72.         $description = mysql_error();
  73.         $number = mysql_errno();
  74.         $error ="MySQL Error : $message\n";
  75.         $error.="Error Number: $number $description\n";
  76.         $error.="Date        : ".date("D, F j, Y H:i:s")."\n";
  77.         $error.="IP          : ".getenv("REMOTE_ADDR")."\n";
  78.         $error.="Browser     : ".getenv("HTTP_USER_AGENT")."\n";
  79.         $error.="Referer     : ".getenv("HTTP_REFERER")."\n";
  80.         $error.="PHP Version : ".PHP_VERSION."\n";
  81.         $error.="OS          : ".PHP_OS."\n";
  82.         $error.="Server      : ".getenv("SERVER_SOFTWARE")."\n";
  83.         $error.="Server Name : ".getenv("SERVER_NAME")."\n";
  84.         $error.="Script Name : ".getenv("SCRIPT_NAME")."\n";
  85.         echo "<b><font size=4 face=Arial>$message</font></b><hr>";
  86.         echo "<pre>$error</pre>";
  87.         exit();
  88.     }
  89.  
  90. }