Ver Mensaje Individual
  #7 (permalink)  
Antiguo 12/06/2012, 17:35
lajaso
 
Fecha de Ingreso: junio-2012
Mensajes: 5
Antigüedad: 11 años, 11 meses
Puntos: 0
Respuesta: Conexion con base de datos

Cita:
Iniciado por scorpion3d Ver Mensaje
Te debería quedar mas o menos así mira:

Código:
<?php
//Configuracion de la conexion a base de datos
$bd_host = "mysql8.000webhost.com"; 
$bd_usuario = "codigousuario_miusuario"; 
$bd_password = "micontraseña"; 
$bd_base = "codigousuario_mibasededatos"; 
$con = mysql_connect($bd_host, $bd_usuario, $bd_password); 
mysql_select_db($bd_base, $con); 
?>
en ese host te dan un codigo de usuario que es con el que entras al ftp

usalo antes del nombre de tu base de datos y nombre de usuario para el mysql, seguido de un guion bajo "_" y el nombre de la base de datos, y lo mismo para el usuario
mira hice esto:
Código PHP:
Ver original
  1. <?php
  2.  
  3.         $ezsql_mysql_str = array
  4.         (
  5.                 1 => 'Require $dbuser and $dbpassword to connect to a database server',
  6.                 2 => 'Error establishing mySQL database connection. Correct user/password? Correct hostname? Database server running?',
  7.                 3 => 'Require $dbname to select a database',
  8.                 4 => 'mySQL database connection is not active',
  9.                 5 => 'Unexpected error while trying to select database'
  10.         );
  11.  
  12.  
  13.         if ( ! function_exists ('mysql_connect') ) die('<b>Fatal Error:</b> ezSQL_mysql requires mySQL Lib to be compiled and or linked in to the PHP engine');
  14.         if ( ! class_exists ('ezSQLcore') ) die('<b>Fatal Error:</b> ezSQL_mysql requires ezSQLcore (ez_sql_core.php) to be included/loaded before it can be used');
  15.  
  16.         class ezSQL_mysql extends ezSQLcore
  17.         {
  18.  
  19.                 var $dbuser = false;
  20.                 var $dbpassword = false;
  21.                 var $dbname = false;
  22.                 var $dbhost = false;
  23.  
  24.  
  25.                 function ezSQL_mysql($dbuser='ausuario_usuario', $dbpassword='pass', $dbname='ausuario_ban', $dbhost='mysql8.000webhost.com')
  26.                 {
  27.                         $this->dbuser = $dbuser;
  28.                         $this->dbpassword = $dbpassword;
  29.                         $this->dbname = $dbname;
  30.                         $this->dbhost = $dbhost;
  31.                 }
  32.  
  33.                 function quick_connect($dbuser='ausuario_usuario', $dbpassword='pass', $dbname='ausuario_ban', $dbhost='mysql8.000webhost.com')
  34.                 {
  35.                         $return_val = false;
  36.                         if ( ! $this->connect($dbuser, $dbpassword, $dbhost,true) ) ;
  37.                         else if ( ! $this->select($dbname) ) ;
  38.                         else $return_val = true;
  39.                         return $return_val;
  40.                 }
  41.  
  42.  
  43.                 function connect($dbuser='ausuario_ban', $dbpassword='pass', $dbhost='mysql8.000webhost.com')
  44.                 {
  45.                         global $ezsql_mysql_str; $return_val = false;
  46.  
  47.                         if ( ! $dbuser )
  48.                         {
  49.                                 $this->register_error($ezsql_mysql_str[1].' in '.__FILE__.' on line '.__LINE__);
  50.                                 $this->show_errors ? trigger_error($ezsql_mysql_str[1],E_USER_WARNING) : null;
  51.                         }
  52.                         else if ( ! $this->dbh = @mysql_connect($dbhost,$dbuser,$dbpassword,true) )
  53.                         {
  54.                                 $this->register_error($ezsql_mysql_str[2].' in '.__FILE__.' on line '.__LINE__);
  55.                                 $this->show_errors ? trigger_error($ezsql_mysql_str[2],E_USER_WARNING) : null;
  56.                         }
  57.                         else
  58.                         {
  59.                                 $this->dbuser = $dbuser;
  60.                                 $this->dbpassword = $dbpassword;
  61.                                 $this->dbhost = $dbhost;
  62.                                 $return_val = true;
  63.                         }
  64.  
  65.                         return $return_val;
  66.                 }
  67.  
  68.  
  69.                 function select($dbname='countries')
  70.                 {
  71.                         global $ezsql_mysql_str; $return_val = false;
  72.  
  73.                         if ( ! $dbname )
  74.                         {
  75.                                 $this->register_error($ezsql_mysql_str[3].' in '.__FILE__.' on line '.__LINE__);
  76.                                 $this->show_errors ? trigger_error($ezsql_mysql_str[3],E_USER_WARNING) : null;
  77.                         }
  78.  
  79.                         else if ( ! $this->dbh )
  80.                         {
  81.                                 $this->register_error($ezsql_mysql_str[4].' in '.__FILE__.' on line '.__LINE__);
  82.                                 $this->show_errors ? trigger_error($ezsql_mysql_str[4],E_USER_WARNING) : null;
  83.                         }
  84.  
  85.                         else if ( !@mysql_select_db($dbname,$this->dbh) )
  86.                         {
  87.                                 if ( !$str = @mysql_error($this->dbh))
  88.                                           $str = $ezsql_mysql_str[5];
  89.  
  90.                                 $this->register_error($str.' in '.__FILE__.' on line '.__LINE__);
  91.                                 $this->show_errors ? trigger_error($str,E_USER_WARNING) : null;
  92.                         }
  93.                         else
  94.                         {
  95.                                 $this->dbname = $dbname;
  96.                                 $return_val = true;
  97.                         }
  98.  
  99.                         return $return_val;
  100.                 }
  101.  
  102.  
  103.                 function escape($str)
  104.                 {
  105.                         if ( ! isset($this->dbh) || ! $this->dbh )
  106.                         {
  107.                                 $this->connect($this->dbuser, $this->dbpassword, $this->dbhost);
  108.                                 $this->select($this->dbname);
  109.                         }
  110.  
  111.                         return mysql_real_escape_string(stripslashes($str));
  112.                 }
  113.  
  114.  
  115.                 function sysdate()
  116.                 {
  117.                         return 'NOW()';
  118.                 }
  119.  
  120.  
  121.                 function query($query)
  122.                 {
  123.  
  124.                         $return_val = 0;
  125.  
  126.                         $this->flush();
  127.  
  128.                         $query = trim($query);
  129.  
  130.                         $this->func_call = "\$db->query(\"$query\")";
  131.  
  132.                         $this->last_query = $query;
  133.  
  134.                         $this->num_queries++;
  135.  
  136.                         if ( $cache = $this->get_cache($query) )
  137.                         {
  138.                                 return $cache;
  139.                         }
  140.  
  141.                         if ( ! isset($this->dbh) || ! $this->dbh )
  142.                         {
  143.                                 $this->connect($this->dbuser, $this->dbpassword, $this->dbhost);
  144.                                 $this->select($this->dbname);
  145.                         }
  146.  
  147.                         $this->result = @mysql_query($query,$this->dbh);
  148.  
  149.                         if ( $str = @mysql_error($this->dbh) )
  150.                         {
  151.                                 $is_insert = true;
  152.                                 $this->register_error($str);
  153.                                 $this->show_errors ? trigger_error($str,E_USER_WARNING) : null;
  154.                                 return false;
  155.                         }
  156.  
  157.                         $is_insert = false;
  158.                         if ( preg_match("/^(insert|delete|update|replace)\s+/i",$query) )
  159.                         {
  160.                                 $this->rows_affected = @mysql_affected_rows();
  161.  
  162.                                 if ( preg_match("/^(insert|replace)\s+/i",$query) )
  163.                                 {
  164.                                         $this->insert_id = @mysql_insert_id($this->dbh);
  165.                                 }
  166.  
  167.                                 $return_val = $this->rows_affected;
  168.                         }
  169.                         else
  170.                         {
  171.  
  172.                                 $i=0;
  173.                                 while ($i < @mysql_num_fields($this->result))
  174.                                 {
  175.                                         $this->col_info[$i] = @mysql_fetch_field($this->result);
  176.                                         $i++;
  177.                                 }
  178.  
  179.                                 $num_rows=0;
  180.                                 while ( $row = @mysql_fetch_object($this->result) )
  181.                                 {
  182.                                         $this->last_result[$num_rows] = $row;
  183.                                         $num_rows++;
  184.                                 }
  185.  
  186.                                 @mysql_free_result($this->result);
  187.  
  188.                                 $this->num_rows = $num_rows;
  189.  
  190.                                 $return_val = $this->num_rows;
  191.                         }
  192.  
  193.                         $this->store_cache($query,$is_insert);
  194.  
  195.                         $this->trace || $this->debug_all ? $this->debug() : null ;
  196.  
  197.                         return $return_val;
  198.  
  199.                 }
  200.  
  201.         }
  202.  
  203. ?>

pero me dice que hay error en la linea 55 y 76