Ver Mensaje Individual
  #1 (permalink)  
Antiguo 25/02/2008, 15:13
t-udis
 
Fecha de Ingreso: febrero-2008
Mensajes: 37
Antigüedad: 16 años, 2 meses
Puntos: 0
PHP y MySQL: un error que no comprendo.

Saludos a todos.
Soy nuevo en el mundo de PHP. Estoy terminando mis estudios y necesito hacer un pequeño sistema en PHP, pero no logro avanzar. Agradeceria a mucho a todos si alguno me pueden explicar estar problema.
El problema es la inserccion de datos. Aqui les anexos las 4 hojas que me muestran el problema.
1.)CONECTARSE.PHP
<html>
<head>
<title>Sans Titre</title>
</head>
<?
function conectarse()
{
if(!($link=mysql_connect("localhost","root","")))
{
echo "Error conectando a la base de datos prejornadas.";
exit();
}
if (!mysql_select_db("basecurso",$link))
{
echo "Error seleccionando la base de datos no prejornadas.";
exit();
}
return $link;
}
conectarse();
echo "Conexion con la base de datos conseguida prejornadas.<br>";
echo "<hr />\n".
"HAPedit 3.1.11.111 (Febrero 2008 11:30:31 a.m.)";
?>
</body>
</html>
2.)CONEC.PHP
<html>
<head>
<title>Sans Titre</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta name="generator" content="HAPedit 3.1">
</head>
<body bgcolor="#FFFFFF">
<?
function conectarse()
{
if(!($link=mysql_connect("localhost","root","")))
{
exit();
}
if(!mysql_select_db("basecurso",$link))
{
exit();
}
return $link;
}
echo "<hr />\n".
"HAPedit 3.1.11.111 (Febrero 2008 01:06:09 p.m.)";
?>
</body>
</html>
3.)INSERTAREG.PHP
<html>
<head>
<title>Sans Titre</title>
</head>
<body bgcolor="#FFFFFF">
<form action="agregar.php">
<table>
<tr><td> Nombre: </td><td> <input type="text" name="nombre" size="20" maxlenght="30"> </td></tr>
<tr><td> Direccion: </td><td> <input type="text" name="direccion" size="20" maxlenght="30"> </td></tr>
<tr><td> Telefono: </td><td> <input type="text" name="telefono" size="20" maxlenght="30"> </td></tr>
<tr><td> Email: </td><td> <input type="text" name="email" size="20" maxlenght="30"> </td></tr>
<tr><td> Imagen: </td><td> <input type="text" name="imagen" size="20" maxlenght="30"> </td></tr>
</table>
<input type="submit" name="action" value="Grabar">
</form>
<hr>
<?
include("conec.php");
$link=conectarse();
$result=mysql_query("select * from tablacurso",$link);
echo "<hr />\n".
"HAPedit 3.1.11.111 (Febrero 2008 03:30:50 p.m.)";
?>
<table border=1 cellspacing=1 cellpadding=1>
<tr>
<td>&nbsp;Nombre</td><td>&nbsp;Direccion&nbsp;</td><td>&nbsp;Telefono&nbsp;</td><td>&nbsp;Email&nbsp;</td><td>&nbsp;Imagen&nbsp;</td>
</tr>
<?
while($row=mysql_fetch_array($result)){
printf("<tr><td>&nbsp;%s</td><td>&nbsp;%s&nbsp;<td>&nbsp;%s&nbsp;</td><td>&nbsp;%s&nbsp;</td><td>&nbsp;<img src=%s>&nbsp;</td></tr>", $row["nombre"],$row["direccion"],$row["telefono"],$row["email"],$row["imagen"]);
}
mysql_free_result($result);
?>
</table>
</body>
</html>
4.)AGREGAR.PHP
<html>
<head>
<title>Sans Titre</title>
</head>
<body bgcolor="#FFFFFF">
<?
include("conec.php");
$link=conectarse();
$sql="insert into tablacurso (nombre,direccion,telefono,email,imagen) values('$nombre','$direccion','$telefono','$email' ,'$imagen')";
mysql_query($sql,$link);
header("Location: insertareg.php");
echo "<hr />\n".
"HAPedit 3.1.11.111 (Febrero 2008 03:54:58 p.m.)";
?>
</body>
</html>

Es el mismo que esta en una de guia de PDF. Lo estuve haciendo con mi base de datos y no me funciono, decidi hacerlo entonces igual al de la guia y tampoco funciono. En ambos casos me daba el mismo error que es este:
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\agregar.php:11) in C:\xampp\htdocs\agregar.php on line 17.
Lo revise y toda la sintaxis esta bien copiada.
Gracias a todos de antemano. ^_^