Ver Mensaje Individual
  #1 (permalink)  
Antiguo 25/09/2010, 20:25
ramiromd
 
Fecha de Ingreso: agosto-2010
Mensajes: 100
Antigüedad: 13 años, 8 meses
Puntos: 2
Problema con INSERT en bd con PHP??

Buenas, estaba extrañando un poco el foro y decidí buscarme un problema para postear :D.
El tema es el siguiente, se me ocurrio armar una especie de mensajeria interna para sustituir al tipico mailer hecho en php.
Entonces, armé un bd con la siguiente estructura:
Código:
CREATE TABLE IF NOT EXISTS `sms` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `from` varchar(45) NOT NULL,
  `tel` int(15) NOT NULL,
  `case` varchar(30) NOT NULL,
  `text` varchar(2048) CHARACTER SET ucs2 NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
El formulario de mensajeria html es el siguiente:
Código:
                          <form id="form1" method="post" action="send.php">
                            <table width="576" height="111" border="0">
                              <tr>
                                <td>Su E-mail:</td>
                                <td><label for="from"></label>
                                <input type="text" name="from" id="from" /></td>
                              </tr>
                              <tr>
                                <td>Su Teléfono:</td>
                                <td><label for="tel"></label>
                                <input type="text" name="tel" id="tel" /></td>
                              </tr>
                              <tr>
                                <td>Asunto:</td>
                                <td><label for="case"></label>
                                <input type="text" name="case" id="case" /></td>
                              </tr>
                              <tr>
                                <td>Mensaje:</td>
                                <td><label for="sms"></label>
                                <textarea name="sms" id="sms" cols="45" rows="5"></textarea></td>
                              </tr>
                              <tr>
                                <td>&nbsp;</td>
                                <td><input type="submit" name="go" id="go" value="Enviar" /></td>
                              </tr>
                            </table>
                          </form>
El script php que debería subir el mensaje a la bd es el siguiente:
Código:
<?php
//CONEXION
$serversql='sql310.eshost.com.ar';
$usuario='eshos_6252824';
$pass='*******';
$db='eshos_6252824_mensajes';

echo 'Intentando conectar a '.$serversql.'<br>';
echo '<b>Respuesta del servidor:</b> <br> ';
$conexion = @mysql_connect($serversql, $usuario, $pass); // se conecta con el servidor

if (!$conexion){
echo "Error al intentar conectarse con el servidor MySQL<br>";
exit(); 
}else{
echo " Conexion exitosa con el servidor MySQL<br>";
};

if (!mysql_select_db($db, $conexion)){  // selecciona la base de datos
echo "No se pudo conectar correctamente con la Base de datos<br>";
exit();
}else{
echo " Conexion exitosa con la Base de datos<br>";
};


// CONFIGURAR VALORES //
$from = $_POST['from'];
$case = $_POST['case'];
$text = $_POST['sms'];
$tel = $_POST['tel'];
echo $from;
echo $case;
echo $text;
echo $tel;
mysql_query("INSERT INTO sms (from,tel,case,text) VALUES ('$from','$tel','$case','$text')");
?>
La salida luego de ejecutar la operación de enviar el mensaje es la siguiente:
Cita:
Intentando conectar a sql310.eshost.com.ar
Respuesta del servidor:
Conexion exitosa con el servidor MySQL
Conexion exitosa con la Base de datos
[email protected] mundo7070707070
Pero los datos no figuran en la bd. Claramente se ve que los datos del formulario entran al script, xq el echo los imprime; Dreamweaver no me marca errores de sintaxis, la conexión a la bd es exitosa...ya no se por donde pueda venir el tema.
Agradecería cualquier ayudilla jeje.
Un saludo y gracias.