Foros del Web » Programando para Internet » PHP »

Problema con script de encuesta

Estas en el tema de Problema con script de encuesta en el foro de PHP en Foros del Web. Hola a tod@s. Tengo una web modesta con un scritpt de encuestas (Advanced Poll 2.08). Es el típico script php que lo subes a tu ...
  #1 (permalink)  
Antiguo 10/09/2014, 16:09
 
Fecha de Ingreso: diciembre-2008
Mensajes: 10
Antigüedad: 15 años, 4 meses
Puntos: 0
Problema con script de encuesta

Hola a tod@s.
Tengo una web modesta con un scritpt de encuestas (Advanced Poll 2.08). Es el típico script php que lo subes a tu sitio y ejecutas un "index.php" para instalarlo en tu web.
Ha estado funcionando ok mucho tiempo, pero ahora me da el siguiente fallo:

Código PHP:
Ver original
  1. Warning: mysql_connect() [function.mysql-connect]: Connection using old (pre-4.1.1) authentication protocol refused (client option 'secure_auth' enabled)

El script tiene este código para conectar con la db:

Código PHP:
Ver original
  1. function connect() {
  2.         $this->conn_id = mysql_connect($this->db['host'].":".$this->port,$this->db['user'],$this->db['pass']);
  3.         if ($this->conn_id == 0) {
  4.             $this->sql_error("Connection Error");
  5.         }
  6.         if (!mysql_select_db($this->db['dbName'], $this->conn_id)) {
  7.             $this->sql_error("Database Error");
  8.         }
  9.         return $this->conn_id;
  10.     }

Supongo que esa sintaxis se ha quedado obsoleta, pero estoy bastante perdido y no sé que sintaxis debería usar para solucionar el problema.

Si alguien me puede echar "un cable" lo agradecería.

La dirección de mi web por si queréis ver el error es esta:

http://abeldg.webcindario.com

Saludos a tod@s!!
  #2 (permalink)  
Antiguo 10/09/2014, 18:07
Avatar de Patriarka  
Fecha de Ingreso: enero-2011
Ubicación: Moreno, Buenos Aires, Argentina
Mensajes: 2.851
Antigüedad: 13 años, 3 meses
Puntos: 288
Respuesta: Problema con script de encuesta

tu servidor tuvo un cambio en la version de mysql
el problema es por que tenes un password INSEGURO , ahora debe tener una cierta cantidad de caracteres
  #3 (permalink)  
Antiguo 10/09/2014, 18:13
Avatar de juan_14nob  
Fecha de Ingreso: abril-2010
Mensajes: 552
Antigüedad: 14 años
Puntos: 6
Respuesta: Problema con script de encuesta

mysql_connect() ya esta deprecated, ahora tienes que usar mysqli

Verifica que el usuario y clave sean los correctos.

__________________
El castellano es un idioma hermoso, por favor no lo alteres, no lo modifiques, escribe correctamente.
  #4 (permalink)  
Antiguo 11/09/2014, 07:48
 
Fecha de Ingreso: diciembre-2008
Mensajes: 10
Antigüedad: 15 años, 4 meses
Puntos: 0
Respuesta: Problema con script de encuesta

Hola, gracias a los dos.
Probaré a poner un password mas complejo y ver que tal.
Comentaré el resultado.
Saludos.
  #5 (permalink)  
Antiguo 11/09/2014, 08:26
 
Fecha de Ingreso: diciembre-2008
Mensajes: 10
Antigüedad: 15 años, 4 meses
Puntos: 0
Respuesta: Problema con script de encuesta

Vale. He probado con un password mas complejo y nada...
He probado a cambiar la sintaxis pero no lo he hecho bien. Sobre el código original que puse me podéis decir cómo tendría que quedar?
Gracias.
  #6 (permalink)  
Antiguo 11/09/2014, 08:40
 
Fecha de Ingreso: diciembre-2008
Mensajes: 10
Antigüedad: 15 años, 4 meses
Puntos: 0
Respuesta: Problema con script de encuesta

Perdonad que sea tan plasta... Os pongo el código completo original del archivo que creo está mal o con sintaxis obsoleta.
Sobre el ¿Qué cambios debería hacer para corregirlo?
Gracias.
  #7 (permalink)  
Antiguo 11/09/2014, 08:41
 
Fecha de Ingreso: diciembre-2008
Mensajes: 10
Antigüedad: 15 años, 4 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. }
  #8 (permalink)  
Antiguo 11/09/2014, 12:10
Avatar de juan_14nob  
Fecha de Ingreso: abril-2010
Mensajes: 552
Antigüedad: 14 años
Puntos: 6
Respuesta: Problema con script de encuesta

Hola, tienes que usar mysqli_connect()

http://php.net/manual/es/function.mysqli-connect.php


__________________
El castellano es un idioma hermoso, por favor no lo alteres, no lo modifiques, escribe correctamente.

Etiquetas: encuesta, mysql, select, sql
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 16:34.