Foros del Web » Programando para Internet » PHP »

Problema conexión base de datos remota

Estas en el tema de Problema conexión base de datos remota en el foro de PHP en Foros del Web. Hola Tengo una base de datos en un servidor "icdsoft", ya habilitada para acceso remoto. Por otra parte intento conectarme a esa base de datos ...
  #1 (permalink)  
Antiguo 04/01/2009, 06:18
 
Fecha de Ingreso: noviembre-2005
Mensajes: 9
Antigüedad: 18 años, 4 meses
Puntos: 0
Problema conexión base de datos remota

Hola

Tengo una base de datos en un servidor "icdsoft", ya habilitada para acceso remoto.

Por otra parte intento conectarme a esa base de datos desde otro servidor "aruba", mediante phpbb de un mkportal con los datos de acceso remoto que me proporciona el servidor en el cual se encuentra la base de datos.

Sin embargo tras un largo rato de página en blanco cargando, me sale:

Cita:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

El código mediante el cual conecto es:

Código:
<?php
$dbms = 'mysql';
$dbhost = 'mysql5.server262.com';
$dbport = '3307';
$dbname = 'nombre';
$dbuser = 'usuario';
$dbpasswd = 'contraseña';
$table_prefix = '';
$acm_type = 'file';
$load_extensions = '';

class dbal
{
	var $db_connect_id;
	var $query_result;
	var $return_on_error = false;
	var $transaction = false;
	var $sql_time = 0;
	var $num_queries = array();
	var $open_queries = array();

	var $curtime = 0;
	var $query_hold = '';
	var $html_hold = '';
	var $sql_report = '';
	
	var $persistency = false;
	var $user = '';
	var $server = '';
	var $dbname = '';

	// Set to true if error triggered
	var $sql_error_triggered = false;

	// Holding the last sql query on sql error
	var $sql_error_sql = '';
	// Holding the error information - only populated if sql_error_triggered is set
	var $sql_error_returned = array();
	
	// Holding transaction count
	var $transactions = 0;

	// Supports multi inserts?
	var $multi_insert = false;

	/**
	* Current sql layer
	*/
	var $sql_layer = '';

	/**
	* Wildcards for matching any (%) or exactly one (_) character within LIKE expressions
	*/
	var $any_char;
	var $one_char;

	/**
	* Constructor
	*/
	function dbal()
	{
		$this->num_queries = array(
			'cached'		=> 0,
			'normal'		=> 0,
			'total'			=> 0,
		);

		// Fill default sql layer based on the class being called.
		// This can be changed by the specified layer itself later if needed.
		$this->sql_layer = substr(get_class($this), 5);

		// Do not change this please! This variable is used to easy the use of it - and is hardcoded.
		$this->any_char = chr(0) . '%';
		$this->one_char = chr(0) . '_';
	}

	/**
	* return on error or display error message
	*/
	function sql_return_on_error($fail = false)
	{
		$this->sql_error_triggered = false;
		$this->sql_error_sql = '';

		$this->return_on_error = $fail;
	}

	
	/**
	* DBAL garbage collection, close sql connection
	*/
	function sql_close()
	{
		if (!$this->db_connect_id)
		{ return false; }

		if ($this->transaction)
		{              do
			{  $this->sql_transaction('commit');
			}
			while ($this->transaction);
		}

		foreach ($this->open_queries as $query_id)
		{
			$this->sql_freeresult($query_id);
		}
		
		return $this->_sql_close();
	}

	/**
	* display sql error page
	*/
	function sql_error($sql = '')
	{
		global $auth, $user, $config;

		// Set var to retrieve errored status
		$this->sql_error_triggered = true;
		$this->sql_error_sql = $sql;

		$this->sql_error_returned = $this->_sql_error();

		if (!$this->return_on_error)
		{
			$message = 'SQL ERROR [ ' . $this->sql_layer . ' ]<br /><br />' . 

$this->sql_error_returned['message'] . ' [' . $this->sql_error_returned['code'] . ']';

			// Show complete SQL error and path to administrators only
			// Additionally show complete error on installation or if extended debug mode is enabled
			// The DEBUG_EXTRA constant is for development only!
			if ((isset($auth) && $auth->acl_get('a_')) || defined('IN_INSTALL') || defined('DEBUG_EXTRA'))
			{
				// Print out a nice backtrace...
				$backtrace = get_backtrace();

				$message .= ($sql) ? '<br /><br />SQL<br /><br />' . htmlspecialchars($sql) : '';
				$message .= ($backtrace) ? '<br /><br />BACKTRACE<br />' . $backtrace : '';
				$message .= '<br />';
			}
			else
			{
				// If error occurs in initiating the session we need to use a pre-defined language string
				// This could happen if the connection could not be established for example (then we are not 

able to grab the default language)
				if (!isset($user->lang['SQL_ERROR_OCCURRED']))
				{
					$message .= '<br /><br />An sql error occurred while fetching this page. Please 

contact an administrator if this problem persists.';
				}
				else
				{
					if (!empty($config['board_contact']))
					{
						$message .= '<br /><br />' . sprintf($user->lang['SQL_ERROR_OCCURRED'], '<a 

href="mailto:' . htmlspecialchars($config['board_contact']) . '">', '</a>');
					}
					else
					{
						$message .= '<br /><br />' . sprintf($user->lang['SQL_ERROR_OCCURRED'], '', 

'');
					}
				}
			}

			if ($this->transaction)
			{
				$this->sql_transaction('rollback');
			}

			if (strlen($message) > 1024)
			{
				// We need to define $msg_long_text here to circumvent text stripping.
				global $msg_long_text;
				$msg_long_text = $message;

				trigger_error(false, E_USER_ERROR);
			}

			trigger_error($message, E_USER_ERROR);
		}

		if ($this->transaction)
		{
			$this->sql_transaction('rollback');
		}

		return $this->sql_error_returned;
	}

}

/**
* This variable holds the class name to use later
*/
$sql_db = (!empty($dbms)) ? 'dbal_' . basename($dbms) : 'dbal';

class dbal_mysql extends dbal
{
	var $mysql_version;
	var $multi_insert = true;

	/**
	* Connect to server
	* @access public
	*/
	function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port, $persistency = false, $new_link = false)
	{
		$this->persistency = $persistency;
		$this->user = $sqluser;
		$this->server = $sqlserver . (($port) ? ':' . $port : '');
		$this->dbname = $database;

		$this->sql_layer = 'mysql4';

		$this->db_connect_id = ($this->persistency) ? @mysql_pconnect($this->server, $this->user, $sqlpassword, 

$new_link) : @mysql_connect($this->server, $this->user, $sqlpassword, $new_link);

		if ($this->db_connect_id && $this->dbname != '')
		{
			if (@mysql_select_db($this->dbname, $this->db_connect_id))
			{
				// Determine what version we are using and if it natively supports UNICODE
				$this->mysql_version = mysql_get_server_info($this->db_connect_id);

				if (version_compare($this->mysql_version, '4.1.3', '>='))
				{
					@mysql_query("SET NAMES 'utf8'", $this->db_connect_id);
					// enforce strict mode on databases that support it
					if (version_compare($this->mysql_version, '5.0.2', '>='))
					{
						$result = @mysql_query('SELECT @@session.sql_mode AS sql_mode', 

$this->db_connect_id);
						$row = @mysql_fetch_assoc($result);
						@mysql_free_result($result);
						$modes = array_map('trim', explode(',', $row['sql_mode']));

						// TRADITIONAL includes STRICT_ALL_TABLES and STRICT_TRANS_TABLES
						if (!in_array('TRADITIONAL', $modes))
						{
							if (!in_array('STRICT_ALL_TABLES', $modes))
							{
								$modes[] = 'STRICT_ALL_TABLES';
							}

							if (!in_array('STRICT_TRANS_TABLES', $modes))
							{
								$modes[] = 'STRICT_TRANS_TABLES';
							}
						}

						$mode = implode(',', $modes);
						@mysql_query("SET SESSION sql_mode='{$mode}'", $this->db_connect_id);
					}
				}
				else if (version_compare($this->mysql_version, '4.0.0', '<'))
				{
					$this->sql_layer = 'mysql';
				}

				return $this->db_connect_id;
			}
		}

		return $this->sql_error('');
	}

	/**
	* Version information about used database
	*/
	function sql_server_info()
	{
		return 'MySQL ' . $this->mysql_version;
	}

		
	/**
	* return sql error array
	* @access private
	*/
	function _sql_error()
	{
		if (!$this->db_connect_id)
		{
			return array(
				'message'	=> @mysql_error(),
				'code'		=> @mysql_errno()
			);
		}

		return array(
			'message'	=> @mysql_error($this->db_connect_id),
			'code'		=> @mysql_errno($this->db_connect_id)
		);
	}

	/**
	* Close sql connection
	* @access private
	*/
	function _sql_close()
	{
		return @mysql_close($this->db_connect_id);
	}

}

$db			= new $sql_db();
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, defined('PHPBB_DB_NEW_LINK') ? PHPBB_DB_NEW_LINK : false);

echo "conectado";

?>

¿Qué puede estar pasando?, ya no se me ocurre qué hacer para arreglarlo
  #2 (permalink)  
Antiguo 04/01/2009, 07:50
Avatar de XLogus  
Fecha de Ingreso: noviembre-2008
Ubicación: AQP
Mensajes: 495
Antigüedad: 15 años, 5 meses
Puntos: 19
Respuesta: Problema conexión base de datos remota

Hola
Generalmente ese error:
Cita:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Me aparece con problemas de configuracion o errores en el archivo .httaccess y no guarda relación con la base de datos, para comprobar borra tu conexión con base de datos un rato y ve si continua el error (lo mas probable es que continue).

2do. no todos los servidores soportan el acceso remoto, verifica eso y verifica que configuraste el acceso remoto para el ip correcto, para descartar eso intenta acceder a tu base de datos desde su propio servidor u otro.
  #3 (permalink)  
Antiguo 04/01/2009, 08:41
Avatar de tata009  
Fecha de Ingreso: septiembre-2008
Ubicación: En mi casa
Mensajes: 426
Antigüedad: 15 años, 7 meses
Puntos: 3
Respuesta: Problema conexión base de datos remota

fijate que no tenga permisos 777 porque hay hostings que no por seguridad no te lo dejan poner archivos en permisos 777 y te largan el error 500 que es justamente el q te aparece a vos


saludos
__________________
SI pones un CD de MIcrosoft al reves aparecen mensajes satanicos pero si lo pones a la derecha PEOR SE TE INSTALA WINDOWS!!!!
Para webmasters e informaticos
  #4 (permalink)  
Antiguo 04/01/2009, 09:14
 
Fecha de Ingreso: noviembre-2005
Mensajes: 9
Antigüedad: 18 años, 4 meses
Puntos: 0
Respuesta: Problema conexión base de datos remota

Gracias por las ideas, pero no parece que sea eso

Solo aparece el error cuando intento conectar a la base de datos remota, si conecto a la propia del servidor accede perfectamente


El archivo de php desde el que intento conectar tiene permisos 755 y ademas si en ese archivo pongo los datos de a base de datos propia del servidor conecta pero falla cuando le pongo los datos de la base de datos remota...

Ya me desespero :( no sé qué hacer.


¿Tendrá algo que ver con la configuración del servidor de aruba desde el que intento hacer la conexión remota? Supongo que si el errror es el Internal Server Error es de es servidor y o de la bd a la que me estoy conectando
  #5 (permalink)  
Antiguo 04/01/2009, 18:03
 
Fecha de Ingreso: noviembre-2005
Mensajes: 9
Antigüedad: 18 años, 4 meses
Puntos: 0
Respuesta: Problema conexión base de datos remota

Esto es lo que aparece en el log del servidor

Cita:
[Mon Jan 05 00:52:50 2009] [warn] [client 83.231.16.73] Timeout waiting for output from CGI script /web/htdocs/www.pagina.com/home/foro/prueba_conexion.php
[Mon Jan 05 00:52:51 2009] [error] [client 83.231.16.73] PHP Fatal error: SQL ERROR [ mysql4 ]

Can't connect to MySQL server on 'mysql5.server262.com' (4) [2003]

An sql error occurred while fetching this page. Please contact an administrator if this problem persists. in /web/htdocs/www.pagina.com/home/foro/prueba_conexion.php on line 615
  #6 (permalink)  
Antiguo 05/01/2009, 07:23
Avatar de XLogus  
Fecha de Ingreso: noviembre-2008
Ubicación: AQP
Mensajes: 495
Antigüedad: 15 años, 5 meses
Puntos: 19
Respuesta: Problema conexión base de datos remota

Si estas seguro la dirección del servidor sql es correcta "mysql5.server262.com", en la parte donde habilitas el acceso externo de la base de datos imagino que haz configurado un ip "83.231.16.73", haz la prueba de agregar como ip "%" si unicamente el simbolo de porcentaje esto permite que cualquier ip acceda a la base de datos solo hazlo para probar si aun asi no funciona creo qu deberias consultar al soporte de tu servidor es posible que el acceso remoto no este habilitado.
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 10:47.