Hola, pues aye stoy algo esesperado frente a esto no logro conectar o que llegen los datos a la Base de Datos, no se cual es mi error. Aqui les dejo los codigos que tengo, Gracias ojala pueden ayudarme, ya que no se cual es mi Error.
Codigo, formualrio.php:
Código HTML:
<table align="center" cellpadding="0" cellspacing="0">
<form action="enviar.php" method="post">
<tr>
<td width="324" height="2" colspan="2"></td>
</tr>
<tr>
<td width="121" height="27"><div align="center">Titulo</div></td>
<td width="203" height="27"><div align="center">
<input type="text" name="mombre" size="20">
</div></td>
</tr>
<tr>
<td width="121" height="20"><div align="center">Imagen</div></td>
<td width="203" height="20"><div align="center">
<input type="text" name="iamgen" size="20">
</div></td>
</tr>
<tr>
<td width="121" height="24"><div align="center">Categoria</div></td>
<td width="203" height="24"><div align="center">
<select name="categoria">
<option>Juegos</option>
<option>Objetos</option>
<option>Pets</option>
<option>Petpets</option>
<option>Duelodromo</option>
<option>Aleatorios</option>
<option>Faciles</option>
<option>Lugares</option>
</select>
</div></td>
</tr>
<tr>
<td width="121" height="17"><div align="center">Dificultad</div></td>
<td width="203" height="17">
<div align="center">
<select name="dificultad">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
</div></td>
</tr>
<tr>
<td width="121" height="17"><div align="center">Detalles</div></td>
<td width="203" height="17"><div align="center">
<textarea name="detalles" cols="20"></textarea>
</div></td>
</tr>
<tr>
<td width="121" height="21"><div align="center">Otros</div></td>
<td width="203" height="21"><div align="center">
<input name="otros" type="text" id="otros" size="20">
</div></td>
</tr>
<tr>
<td width="324" height="4" colspan="2">
<div align="center">
<input type="submit" value="Enviar">
</div></td>
</tr>
</form>
</table>
Codigo, enviar.php:
Código PHP:
<?php
$d_host = "localhost"; // MySQL server host
$d_user = ""; // MySQL username
$d_pass = ""; // MySQL password
$db_name = "prueba";
//La conexión
$coneccion = mysql_connect($d_host,$d_user,$d_pass) or die ('No se Puede Conecatar a ala Base de Dtao, ya que: ' . mysql_error());
mysql_select_db($db_name,$coneccion);
# se recogen los datos del formulario
$nombre = $_POST['nombre'];
$imagen = $_POST['imagen'];
$categoria = $_POST['categoria'];
$dificultad = $_POST['dificultad'];
$detalles = $_POST['detalles'];
$otros = $_POST['otros'];
//Insertando en la base de datos
$sql="INSERT INTO avatars (nombre,imagen,categoria,dificultad,detalles,otros) VALUES ('.$nombre.', '.$imagen.','.$categoria.','.$dificultad.','.$detalles.','.$otros.')";
mysql_query($sql,$coneccion);
mysql_close($coneccion);
?>
Tabla de Mysql:
Código:
CREATE TABLE `avatars` (
`id` INT( 10 ) NOT NULL AUTO_INCREMENT ,
`nombre` VARCHAR( 100 ) NOT NULL ,
`imagen` VARCHAR( 100 ) NOT NULL ,
`categoria` VARCHAR( 80 ) NOT NULL ,
`dificultad` VARCHAR( 10 ) NOT NULL ,
`detalles` VARCHAR( 1000 ) NOT NULL ,
`otros` VARCHAR( 300 ) NOT NULL ,
PRIMARY KEY ( `id` )
) TYPE = MYISAM ;
Quisiera saber tamebin como hago para seleccionar la tabala en donde se deben almacenar los datos, ps no e podido dar con eso tampoco ....
Haber si me pueden ayudar ... Gracias