ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> php-windows
php-windows
RE: [PHP-WIN] why do i have this error???
by Dash McElroy other posts by this author
Aug 1 2002 8:18PM messages near this date
Re: [PHP-WIN] php cookie question | [PHP-WIN] DaDaBIK 2.1b beta released
The header() command is very sensitive. No data (including a stray space)
can be sent to the browser before a header() command is called. If you take
out the include(conex.php); line (or just take out the data that it echoes
to the browser) you'll be in fine shape.

-Dash 

-----Original Message-----
From: Adolfo Meneses [mailto:adolfo-meneses@[...].com] 
Sent: Thursday, August 01, 2002 1:01 PM
To: php-windows@[...].net
Subject: [PHP-WIN] why do i have this error???


Hello, Im trying to learn how to develop aplications with php, I took this
from a tutorial, but I get an error message. The situation is very simple.
Please somebody help me out.
Thanks.

Adolfo

this is the error message:
Warning: Cannot add header information - headers already sent by (output
started at c:\apache\htdocs\adul\conex.php:2) in
c:\apache\htdocs\adul\inserta.php on line 20



the files involved are these:
altas.php

<html> 
<head> 
   <title> Altas de Afiliados</title>
</head> 
<body> 
<H1> Ingrese los valores correspondientes.</H1>
<FORM ACTION="inserta.php"> 
<TABLE> 
<TR> 
   <TD> Nro. Afiliado:</TD>
   <TD> <INPUT TYPE="text" NAME="nro_afil" SIZE="20" MAXLENGTH="30"></TD>
</TR> 
<TR> 
   <TD> Apellido:</TD>
   <TD> <INPUT TYPE="text" NAME="apellido" SIZE="20" MAXLENGTH="30"></TD>
</TR> 
<TR> 
   <TD> Nombres:</TD>
   <TD> <INPUT TYPE="text" NAME="nombres" SIZE="20" MAXLENGTH="30"></TD>
</TR> 
<TR> 
   <TD> Tipo doc.:</TD>
   <TD> <INPUT TYPE="text" NAME="tipo_doc" SIZE="20" MAXLENGTH="30"></TD>
</TR> 
<TR> 
   <TD> Nro. doc.:</TD>
   <TD> <INPUT TYPE="text" NAME="nro_doc" SIZE="20" MAXLENGTH="30"></TD>
</TR> 
<TR> 
   <TD> Legajo:</TD>
   <TD> <INPUT TYPE="text" NAME="legajo" SIZE="20" MAXLENGTH="30"></TD>
</TR> 

</TABLE> 
<INPUT TYPE="submit" NAME="accion" VALUE="Grabar"> 
</FORM> 
<?
/* verificar si existe, si no ingresar a la base de datos, si existe mostrar
mensaje de error.*/
?> 
<hr> 

</body>  
</html>  


inserta.php
<?php
   include("conex.php");
   $link=Conectarse();
   mysql_query("insert into lista2 (
                       nro_afil,
                       apellido,
                       nombres,
                       tipo_doc,
                       nro_doc,
                       legajo
               ) values (
                       '$nro_afil',
                       '$apellido',
                       '$nombres',
                       '$tipo_doc',
                       '$nro_doc',
                       '$legajo'
                       )",$link);

   header("Location: altas.php");
?> 

Conex.php
<!--conectando lista2 en php--> 
<?php
function Conectarse()
{
if(!($link=mysql_connect("localhost","root")))
{
echo "Error conectando a la base de datos.";
exit();
}
if(!mysql_select_db("lista2",$link))
{
echo "Error seleccionando la base de datos.";
exit();
}
return $link;
}
?> 










-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved