Foros del Web » Programando para Internet » PHP »

Error al iniciar conexión php.

Estas en el tema de Error al iniciar conexión php. en el foro de PHP en Foros del Web. Hola a todos! Me estoy iniciando en este mundo y estoy haciendo pruebas y tal. Al subir la web al hosting me da este error: ...
  #1 (permalink)  
Antiguo 02/03/2012, 03:12
 
Fecha de Ingreso: marzo-2012
Mensajes: 2
Antigüedad: 12 años, 1 mes
Puntos: 0
Error al iniciar conexión php.

Hola a todos!

Me estoy iniciando en este mundo y estoy haciendo pruebas y tal. Al subir la web al hosting me da este error:

Warning: PDO::__construct() expects parameter 4 to be array, string given in /home/a6020842/public_html/registrar.php on line 13

Tengo mi config.php asi:

Código:
<?php
define( "DB_DSN", "mysql:dbname=a6020842_colosal" );
define( "DB_USERNAME", "a6020842_colosal" );
define( "DB_PASSWORD", "xxxxxxxx" );
define( "DB_HOST", "mysql5.000webhost.com" );
define( "PAGE_SIZE", 5 );
define( "TBL_MEMBERS", "members" );
define( "TBL_ACCESS_LOG", "accessLog" );
?>

y mi registrar.php asi, la que está en rojo es la linea del fallo.

Código:
<?php


ini_set('display_errors', 1);
ini_set('log_errors', 1);
ini_set('error_log', dirname(__FILE__) . '/error_log.txt');
error_reporting(E_ALL);

include ("config.php");


try {
	$conn = new PDO (DB_DSN, DB_USERNAME, DB_PASSWORD, DB_HOST);
	$conn->setAttribute (PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
	echo "Fallo de conexion: " . $e->getMessage();
}
Muchas Gracias de antemano.
  #2 (permalink)  
Antiguo 02/03/2012, 03:14
Avatar de repara2  
Fecha de Ingreso: septiembre-2010
Ubicación: München
Mensajes: 2.445
Antigüedad: 13 años, 7 meses
Puntos: 331
Respuesta: Error al iniciar conexión php.

El cuarto parámetro sólo puede ser un array. Consulta el manual: http://www.php.net/manual/es/pdo.construct.php
__________________
Fere libenter homines, id quod volunt, credunt.
  #3 (permalink)  
Antiguo 02/03/2012, 03:47
 
Fecha de Ingreso: marzo-2012
Mensajes: 2
Antigüedad: 12 años, 1 mes
Puntos: 0
Respuesta: Error al iniciar conexión php.

Gracias fiera, ya lo arreglé.

Etiquetas: html, mysql
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 11:56.