Hola a todos, nesesito ayuda de nuervo:
Quiero sabes si este script que hice tiene algo mal.
Consta de 2 archivos:
conexion.php
Código:
<?
$host_db = "localhost";
$usuario_db = "nombre";
$pass_db = "pass";
$base_sb = "nombre_bd";
?>
insdb.php
Código:
<form method="POST" action="insdb.php">
<table width="74%" border="0">
<tr>
<th colspan="2" scope="row">CREACION DE TABLAS MEDIANTE UN FORMULARIO </th>
</tr>
<tr>
<th width="61%" scope="row"><div align="left">Ingrese el nombre que le quiera poner a la tabla : </div></th>
<td width="39%">
<input type="text" name="ntabla">
</td>
</tr>
<tr>
<th height="107" scope="row"><div align="left">Ingrese aqui la estructura de la tabla : </div></th>
<td>
<textarea name="estructura" cols="30" rows="10" ></textarea>
</td>
</tr>
<tr>
<th scope="row"></th>
<td><div align="center">
<input type="submit" value="Enviar" name="enviar">
</div></td>
</tr>
</table>
</form>
<?
include ("conexion.php");
$ntabla = $_POST['ntabla'];
$estructura = $_POST['estructura'];
$sql = "CREATE TABLE " .$ntabla. "(" .$estructura. ");";
$coneccion = mysql_connect($host_db, $usuario_db, $pass_db);
if (!@mysql_select_db($base_sb, $conexion));
{
echo "Imposible abrir la BD";
exit();
if($_POST['enviar'])
{
if(!@mysql_query($sql, $conexion));
{
echo "Error: ".mysql_error(). "<br>";
}else{
echo "Tabla creada con éxito";
}
}
?>
Espero que me puedan ayudar
gracias