Test Foro de elhacker.net SMF 2.1

Programación => Desarrollo Web => PHP => Mensaje iniciado por: BapeMilo en 10 Octubre 2010, 13:30 PM

Título: Ayuda Script Php
Publicado por: BapeMilo en 10 Octubre 2010, 13:30 PM
Archivo Conexion:
Código (php) [Seleccionar]
<?
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "pwd";
$db = "rci";
?>


Archivo Instalar
Código (php) [Seleccionar]
require_once("conexion.php");

switch ($lk) {

case "inicio":



break;

case "parte2":
if (isset($_POST['crear'])) {

$host             = "".$_POST['host_bd']."";
$usuario_bd     = "".$_POST['usuario_bd']."";
$contrasena_bd     = "".$_POST['contrasena_bd']."";
$nombre_bd         = "".$_POST['nombre_bd']."";
$admin             = "".$_POST['admin']."";
$passadmin         = "".$_POST['passadmin']."";

$basedatos = "$nombre_bd";

$link = @mysql_connect("$host", "$usuario_bd", "$contrasena_bd");

// comprobamos que hemos estabecido conexión en el servidor
if (! $link){
echo "<center><br><br>ERROR: Imposible establecer conexión con el servidor.<br><br></center>";
exit();
}

// obtenemos una lista de las bases de datos del servidor
$db = mysql_list_dbs();



// vemos cuantas BD hay
$num_bd = mysql_num_rows($db);


//comprobamos si la BD que queremos crear exite ya
$existe = "NO" ;
for ($i=0; $i<$num_bd; $i++) {
if (mysql_dbname($db, $i) == $basedatos) {
$existe = "SI" ;
break;
}
}

// si no existe la creamos
if ($existe == "NO") {
/* manera 1 */
if (! mysql_create_db($basedatos, $link)) {
echo "<br><br>ERROR 1: Imposible crear base de datos. .<br>";

}
/* manera 2
if (! mysql_query("CREATE DATABASE $basedatos", $link)){
echo "ERROR2: Imposible crear base de datos. <br>";

} */
}


Codigo form incluido en la pagina instalar.php
Código (php) [Seleccionar]
<form target="_self" name="lwd" action="instalar.php?lk=parte2" method="post">

    <table border="0" width="300" cellspacing="1" height="18">
      <center>
      <tr>

      <b>Datos para conexion a la base de datos :</b><br>

      </tr>
        <tr>
          <td width="50%"  height="1">Host :</td>
            <td width="50%" align="left" height="1">
            <input  value="'.$dbhost.'" type="text" name="host_bd" size="20"></td>
          <td width="5%" align="left" height="0">
          ';

  echo"
              <a onMouseOver=\"showmessage('Host donde este tu Base de datos, casi siempre es localhost .')\" onMouseOut=\"hideticker()\" ><img border=\"0\" src=\"imagenes/web/masinfo.gif\" width=\"14\" height=\"14\"></a>
            ";

  echo'
           </td>
            </tr>

      <tr>
        <td width="50%"  height="0">Usuario :</td>
        <td width="45%" align="left" height="0">
          <input value="'.$dbuser.'" type="text" name="usuario_bd" size="20"></td>
          <td width="5%" align="left" height="0">
          ';

  echo"
              <a onMouseOver=\"showmessage('Nombre de usuario para la conexion con la base de datos.')\" onMouseOut=\"hideticker()\" ><img border=\"0\" src=\"imagenes/web/masinfo.gif\" width=\"14\" height=\"14\"></a>
            ";

  echo'
           </td>
      </tr>
      <tr>
        <td width="50%"  height="0">Contraseña :</td>
        <td width="45%" align="left" height="0">
          <input value="'.$dbpass.'" type="text" name="contrasena_bd" size="20"></td>
          <td width="5%" align="left" height="0">
          ';

  echo"
              <a onMouseOver=\"showmessage('Contraseña nesesaria para la conexion con la base de datos.')\" onMouseOut=\"hideticker()\" ><img border=\"0\" src=\"imagenes/web/masinfo.gif\" width=\"14\" height=\"14\"></a>
            ";

  echo'
           </td>
      </tr>
      <tr>
        <td width="50%"  height="0">Base de datos :</td>
        <td width="45%" align="left" height="0">
          <input value="'.$db.'" type="text" name="nombre_bd" size="20"></td>
          <td width="5%" align="left" height="0">
          ';

  echo"
              <a onMouseOver=\"showmessage('Nombre de tu base de datos previamente creada en tu phpmyadmin.')\" onMouseOut=\"hideticker()\" ><img border=\"0\" src=\"imagenes/web/masinfo.gif\" width=\"14\" height=\"14\"></a>
            ";

  echo'
           </td>
      </tr>

  </center>
</table>
<table border="0" width="300" cellspacing="1" height="18">
      <center>

            <tr>

            <br><br><b>Datos para el acceso a la administracion :</b><br>

            </tr>


<tr>

          <td width="50%"  height="1">Administrador :</td>
            <td width="45%" align="left" height="1">
            <input  value="admin" type="text" name="admin" size="20"></td>
          <td width="5%" align="left" height="0">
          ';

  echo"
              <a onMouseOver=\"showmessage('Nombre de administrador nesesario para acceder al panel de administracion de los lanzadores .')\" onMouseOut=\"hideticker()\" ><img border=\"0\" src=\"imagenes/web/masinfo.gif\" width=\"14\" height=\"14\"></a>
            ";

  echo'
           </td>
            </tr>

      <tr>
        <td width="50%"  height="0">contraseña :</td>
        <td width="45%" align="left" height="0">
          <input value="admin" type="text" name="passadmin" size="20"></td>
          <td width="5%" align="left" height="0">
          ';

  echo"
              <a onMouseOver=\"showmessage('Contraseña nesesaria para acceder al panel de administracion de los lanzadores.')\" onMouseOut=\"hideticker()\" ><img border=\"0\" src=\"imagenes/web/masinfo.gif\" width=\"14\" height=\"14\"></a>
            ";

  echo'
           </td>
      </tr>
        </center>
</table>
<table border="0" width="300" cellspacing="1" height="18">
      <center>
      <tr>
      <br><br>
        <td width="50%"  height="0"><input type="submit" value="Enviar" name="crear" size="20"></td>
      <td width="50%" align="left" height="0"><input type="reset" value="Restablecer" name="B2" size="20"></td>
     </tr>

  </center>
</table>

</form>
</div>
';
}
else
{
echo "<br>
<center>Por favor para poder continuar tienes que darle permisos de ecritura <br> al archivo con nombre :
<br><b>conexion.php</b></center>

";

}

break;


Nose porque no me carga el formulario form al darle enviar veis algun error de codigo lo he revisado vastantes veces
Título: Re: Ayuda Script Php
Publicado por: ~ Yoya ~ en 10 Octubre 2010, 17:34 PM
Verifica que la directiva display_errors del php.ini este activada...

Código (php) [Seleccionar]
<?php
if(!ini_get('display_errors')){
echo 
"La directiva display_errors esta Desactivada";
exit;
}
echo 
"La directiva esta activada";
 
?>


Luego mira el error que te da el source...
Título: Re: Ayuda Script Php
Publicado por: BapeMilo en 10 Octubre 2010, 21:51 PM
No me da ningun error de codigo pero esque tengo un form de instlacion del script y en el form me sale que indique la base de datos el host etc vale al darle a enviar no me carga solo se reinicia llevo rompiendome la cabeza vastante tiempo ademas probe en un awardspace y me instalo pero luego me decia que no detectaba la base de datos :S si alguien me echa alguna mano
Título: Re: Ayuda Script Php
Publicado por: ~ Yoya ~ en 10 Octubre 2010, 23:04 PM
verificaste que la directiva display_errors esye On???

Puedes poner tu configuración del php.ini