Strange output error – PHP

  php

Q(Question):

hi all,

I have this strange error: when I need to use the database on a page I
include connectionDB.php with inculde_once("connectionDB.php");
The connectionDB.php looks like this:

<?
$db = mysql_connect("localhost", "xxxxxx, "xxxxxx");
mysql_select_db("xxxxx",$db);
?>

when I use the header("Location: goto.php"); function after the
connectionDB.php code is included I get
Warning: Cannot modify header information – headers already sent by (output
started at C:\Inetpub\webpub\S11Mate\html01\connectionDB.php: 4) in
C:\Inetpub\webpub\S11Mate\html01\login.php on line 60

This means that connectionDB.php is sending to the browser? Being more
specific, line number 4, ?> . Someone knowswhats going wrong.

kind regards
Stijn

A(Answer):

Stijn Goris wrote:
[…]

The connectionDB.php looks like this:

<?
$db = mysql_connect("localhost", "xxxxxx, "xxxxxx");
mysql_select_db("xxxxx",$db);
?>

____^_

maybe a space there?


I have a spam filter working.
To mail me include "urkxvq" (with or without the quotes)
in the subject line, or your mail will be ruthlessly discarded.

A(Answer):

"Pedro" <he****@hotpop.com> wrote in message
news:bl************@ID-203069.news.uni-berlin.de…

Stijn Goris wrote:
[…]

The connectionDB.php looks like this:

<?
$db = mysql_connect("localhost", "xxxxxx, "xxxxxx");
mysql_select_db("xxxxx",$db);
?>

____^_

maybe a space there?


I have a spam filter working.
To mail me include "urkxvq" (with or without the quotes)
in the subject line, or your mail will be ruthlessly discarded.

I don’t think a space can cause the error. I put spaces and tabs all around
my code to make it better looking.

But the problem has disapeared for some reason.

regards

A(Answer):

On Fri, 26 Sep 2003 18:53:14 +0200, Stijn Goris wrote:

"Pedro" <he****@hotpop.com> wrote in message
news:bl************@ID-203069.news.uni-berlin.de…

Stijn Goris wrote:
[…]

> The connectionDB.php looks like this:
>
><?
> $db = mysql_connect("localhost", "xxxxxx, "xxxxxx");
> mysql_select_db("xxxxx",$db);
> ?>

____^_

maybe a space there?


I have a spam filter working.
To mail me include "urkxvq" (with or without the quotes) in the subject
line, or your mail will be ruthlessly discarded.

I don’t think a space can cause the error. I put spaces and tabs all
around my code to make it better looking.

The space in this case _would_ matter, as this would be sent as "text" to
the browser more than likely before another header call. I fell prey to
this the other day with a script after I insterted a blank line after the
closing ‘?>’ chars. This was in the header section with more header code
below.. and threw the same error your script has done. Removing the blank
line fixed the problem instantly. Tabs / spaces within the <?php ?> tags
are neither here nor there =)

Regards,

Ian


Ian.H [Design & Development]
digiServ Network – Web solutions
www.digiserv.net | irc.digiserv.net | forum.digiserv.net
Programming, Web design, development & hosting.

A(Answer):

"Ian.H" <ia*@WINDOZEdigiserv.net> wrote in message
news:pa****************************@hybris.digiser v.net…

On Fri, 26 Sep 2003 18:53:14 +0200, Stijn Goris wrote:

"Pedro" <he****@hotpop.com> wrote in message
news:bl************@ID-203069.news.uni-berlin.de…

Stijn Goris wrote:
[…]
> The connectionDB.php looks like this:
>
><?
> $db = mysql_connect("localhost", "xxxxxx, "xxxxxx");
> mysql_select_db("xxxxx",$db);
> ?>
____^_

maybe a space there?


I have a spam filter working.
To mail me include "urkxvq" (with or without the quotes) in the subject
line, or your mail will be ruthlessly discarded.

I don’t think a space can cause the error. I put spaces and tabs all
around my code to make it better looking.

The space in this case _would_ matter, as this would be sent as "text" to
the browser more than likely before another header call. I fell prey to
this the other day with a script after I insterted a blank line after the
closing ‘?>’ chars. This was in the header section with more header code
below.. and threw the same error your script has done. Removing the blank
line fixed the problem instantly. Tabs / spaces within the <?php ?> tags
are neither here nor there =)

Regards,

Ian


Ian.H [Design & Development]
digiServ Network – Web solutions
www.digiserv.net | irc.digiserv.net | forum.digiserv.net
Programming, Web design, development & hosting.

Thanks, that makes sence… after the ?> .

kind regards and and great thanks for the help
Stijn

A(Answer):

Stijn Goris wrote:

"Pedro" <he****@hotpop.com> wrote in message
news:bl************@ID-203069.news.uni-berlin.de…

Stijn Goris wrote:
[…]

> The connectionDB.php looks like this:
>
><?
> $db = mysql_connect("localhost", "xxxxxx, "xxxxxx");
> mysql_select_db("xxxxx",$db);
> ?>

____^_

maybe a space there?

I don’t think a space can cause the error. I put spaces and tabs all around
my code to make it better looking.

But the problem has disapeared for some reason.

I tested a file with a space after the closing "?>" and I got that
error. My editor strips trailing spaces on save, so I had to reconfigure
it to be able to test 🙂
Of course it’s now back to the previous configuration.


I have a spam filter working.
To mail me include "urkxvq" (with or without the quotes)
in the subject line, or your mail will be ruthlessly discarded.

A(Answer):

Once you got your the error on your browser, did you try to view the source
by clicking the "Source" option from the "View" menu (if you’re using
Internet Explorer).

You’ll probalby see another error message related to your mysql_connect() or
mysql_db() command.

I guess you have a connection error…
"Pedro" <he****@hotpop.com> wrote in message
news:bl************@ID-203069.news.uni-berlin.de…

Stijn Goris wrote:

"Pedro" <he****@hotpop.com> wrote in message
news:bl************@ID-203069.news.uni-berlin.de…

Stijn Goris wrote:
[…]
> The connectionDB.php looks like this:
>
><?
> $db = mysql_connect("localhost", "xxxxxx, "xxxxxx");
> mysql_select_db("xxxxx",$db);
> ?>
____^_

maybe a space there?

I don’t think a space can cause the error. I put spaces and tabs all
around my code to make it better looking.

But the problem has disapeared for some reason.

I tested a file with a space after the closing "?>" and I got that
error. My editor strips trailing spaces on save, so I had to reconfigure
it to be able to test 🙂
Of course it’s now back to the previous configuration.


I have a spam filter working.
To mail me include "urkxvq" (with or without the quotes)
in the subject line, or your mail will be ruthlessly discarded.

LEAVE A COMMENT