[ELECTRON] PHP - question. . . webcam script...

Gordon JC Pearce gordonjcp at gjcp.net
Sat Apr 3 19:43:38 UTC 2010


On Sat, 2010-04-03 at 00:15 +0100, Ben Rush wrote:
> Hello folks,
> Im going to preface this by stating I'm a self described noob, so if
> this seems elementary - I stand by my assertion.
> I have come to a block and Im not sure how to deal with it, and any
> thought would be amazing.
> 
> Im working on a fetch image script for a webcam and everything seemed
> hunky-dorry.
> 
> I later decided to add an if/else on the off chance the camera wasn't
> available. This is where things got confusing.
> 
> If the camera fails I get a "Warning: Cannot modify header
> information". The thing is I cant figure out were the header info is
> being declared, as the warning seem to indicate that the declaration
> comes from in the 'if' statement itself. Wait didn't that just fail?!?

Something is outputting stuff to the server before you get a chance to
send the header() part.

A quick demonstration - type "telnet www.electronclub.org 80"
Once you get the "Escape character is '^]'." message type
"GET / HTTP/1.0" then <RETURN> <RETURN>

You'll see the server's response - "HTTP/1.1 200 OK" and a bunch of
things like "Date:" and "Length:" and importantly "Content-Type:".
These are the headers.  There's a blank line before the actual content
*and this is very important*.
Once you send that blank line, you cannot send any more headers.

> Moving the 'header('content-type: image/jpg');' higher up in the
> script doesn't seem to fix it. Moving it before the if statement all
> together gives a broken image link - the echo of file contents don't
> seem to make to the browser.
> 
> I also checked to see if there was any empty space before or after my
> <? ?> - no empty echoes there either. .

Can you put the script up in something like pastebin, with line numbers?
That would make it a wee bit easier to trace.

Gordon MM0YEQ




More information about the members mailing list