Código:
y tambien he creado pagina php insertar_datos.php con esto<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="GENERATOR" content="Microsoft FrontPage Express 2.0"> <title>Reservas</title> </head> <body> <form action="insertar_datos.php" method="post" name="webtaller"> <p> </p> <div align="center"><center><table border="0" cellpadding="0" cellspacing="0"> <tr> <td>Nombre:</td> <td><input type="text" size="20" name="Nombre"></td> </tr> <tr> <td>Apellido 1: </td> <td><input type="text" size="20" name="Apellido1"></td> </tr> <tr> <td>Apellido 2:</td> <td><input type="text" size="20" name="Apellido2"></td> </tr> <tr> <td>D.N.I:</td> <td><input type="text" size="20" name="Dni"></td> </tr> <tr> <td>Teléfono:</td> <td><input type="text" size="20" name="Telefono"></td> </tr> <tr> <td>E-mail:</td> <td><input type="text" size="20" name="Email"></td> </tr> <tr> <td>Fecha Inicio</td> <td><input type="text" size="20" name="Fechainicio"></td> </tr> <tr> <td>Fecha Fin</td> <td><input type="text" size="20" name="Fechafin"></td> </tr> <tr> <td>Personas</td> <td><input type="text" size="20" name="Personas"></td> </tr> <tr> <td>Comentarios</td> <td><textarea name="Comentarios" rows="7" cols="37"></textarea></td> </tr> </table> </center></div><p align="center"><input type="submit" name="submit" value="Enviar"></p> </form> </body> </html>
Código:
<?php $link = mysql_connect("xxxxxx","xxxxx","xxxx"); mysql_select_db("xxxxxx",$link); mysql_query("INSERT INTO reservas (Nombre,Apellido1,Apellido2,Dni,Telefono,Email,Fechainicio,Fechafin,Personas,Comentarios) VALUES ('{$_POST['Nombre']}','{$_POST['Apellido1']}','{$_POST['Apellido2']}','{$_POST['Dni']}','{$_POST['Email']}','{$_POST['Fechainicio']}','{$_POST['Fechafin']}','{$_POST['Personas']}','{$_POST['Comentarios']}')",$link); // Ahora comprobaremos que todo ha ido correctamente $my_error = mysql_error($link); if(!empty($my_error) { echo "Ha habido un error al insertar los valores. $my_error"; } else { echo "Los datos han sido introducidos satisfactoriamente"; } } else { echo "Error, no ha introducido todos los datos"; } ?>
El Problema es que me da error en la linea:
Código:
Cambie datos de conexion por xxxxxif(!empty($my_error) {
Alguien me puede decir que estoy haciendo mal?
Gracias.