Forum Moderators: coopster

Message Too Old, No Replies

Header Error

         

apicante

8:16 pm on May 27, 2011 (gmt 0)

10+ Year Member



Hello everyone,

I have already included php in my .htaccess so that it will work on regular html files.

BUT I am getting a header error and I am not sure why? Is it because of where I am putting the php code? How is this suppose to flow? Check it out at - [pastebin.com...]

Thanks for all the help.

jspeed

8:33 pm on May 27, 2011 (gmt 0)

10+ Year Member



Put your include above the <head> tag, see if that works.

apicante

8:38 pm on May 27, 2011 (gmt 0)

10+ Year Member



Still nothing...?

rocknbil

8:41 pm on May 27, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This will error

<!doctype html>
<?php
if ($some_condition) {
header("Location:https://example.com");
}
?>


This will not


<?php
if ($some_condition) {
header("Location:https://example.com");
}
?>
<!doctype html>

When you request a page and it has anything prior to a header, that is output and the server (generally) sends a content-type:text/html header to inform the client of what's coming. So when you try a location (or any other type of header) within PHP, it says "headers already output. (no soup for you)."

apicante

8:44 pm on May 27, 2011 (gmt 0)

10+ Year Member



So what do i change? I appreciate the help rocknbil just need some direction on where i put the code? I am still slightly confused.

Leosghost

8:49 pm on May 27, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



there must be no code at all before the "include" which has the "redirect" in it..

means you add whatever your code is before the doc type line

Btw ( dont know about the other guys here, but )I can't see your code at all on paste bin ..give it a "title"..there are thousands of "untitled" there, every hour.

[edited by: Leosghost at 8:51 pm (utc) on May 27, 2011]

g1smd

8:50 pm on May 27, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Once you have started sending the HTML page it is way too late to send any headers.

The HEADER in the example above will send a 302 redirect by default. Additionally, the canonical URL for the root page should end with a trailing slash.

pastebin returns a blank page for me, so I can't comment on your actual code.

apicante

8:54 pm on May 27, 2011 (gmt 0)

10+ Year Member



[pastebin.com...] - Try that...

I am still very confused..look where i placed it guys, thx for all the help.

I am trying to use the [detectmobilebrowsers.mobi...]

Thanks again.

Leosghost

8:54 pm on May 27, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



the first line of this page you are looking at is is like this ..

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

you would have to put your redirect
like this

redirect<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

apicante

9:34 pm on May 27, 2011 (gmt 0)

10+ Year Member



I changed the beginning to:

<?php require_once('mobile_device_detect.php');
mobile_device_detect(true,true,true,true,true,true,true,'http://www.staticvibes.com/mobile','http://www.staticvibes.com');?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="nivo-slider.css" type="text/css" media="screen" />
<link rel="stylesheet" href="style.css" type="text/css" media="screen" />

<script type="text/javascript" src="scripts/jquery-1.4.3.min.js"></script>
<script type="text/javascript" src="jquery.nivo.slider.pack.js"></script>
<title>RudeboyWorld.com </title>
<style>

Still getting header error. hmm? Check it out staticvibes.com

g1smd

9:53 pm on May 27, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If you send even a single character out before sending all the headers you will generate an error message. That "single character" limitation even includes a blank space. Make sure there are no blank spaces outside of your PHP code in the included file or before the PHP code in the main file.

apicante

9:58 pm on May 27, 2011 (gmt 0)

10+ Year Member



I removed all white space and blanks and its still not working?

Leosghost

10:06 pm on May 27, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Forgive me for asking , but why not ask Andy, the guy you bought the script from , for "implementation support"..?

According to his site "implementation support" is included, when you purchase the the script, for use on a commercial site(s).

apicante

10:10 pm on May 27, 2011 (gmt 0)

10+ Year Member



Just wanted to figure it out on my own and not using this for commercial purposes just test. I am so confused and trying to learn this

Leosghost

10:36 pm on May 27, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



But the sites that you are using it on in your pastebin example(s) source code, are both commercial sites ..with a shop and all..and are live sites..

C'mon ..pay the guy for his script ..ask for his help ..its a nice script ..I've looked at it ..it works if you understand how to implement it ..and for $25.oo per commercial domain its a good deal..there's a lot of coders on WebmasterWorld ..

You had two of them, ( that I know and respect immensely ) at least ( I'm not a pro coder , just an interested tinkerer ) both pro coders ..join in to help ..just to save you $25.oo or $50.oo ..and "Andy" even made it "trustware" <= means free to use ( and he even put all the source code in )unless on commercial sites ..

Testing on commercial sites ..when the sites are live ( yours are )..is commercial use IMO..and probably in the opinion of "Andy" ..the guy who wrote it ..and most members here ..

apicante

11:30 pm on May 27, 2011 (gmt 0)

10+ Year Member



Just paid! guess what...no support!

eta_carinae

9:28 pm on May 28, 2011 (gmt 0)

10+ Year Member



So what is the actual code that doesn't work, this one - www.pastebin.com/ceVZNFzi ?
What is the error?
Check if your www.pastebin.com/ceVZNFzi is in UTF and has www.en.wikipedia.org/wiki/Byte_order_mark. If it has, remove it with www.akelpad.sourceforge.net/en/download.php