My Site is not opening in IE. I know about CSS incompatibilities this is why I added the following code to redirect to a static page if UserAgent belongs to Internet Explorer. The code that detects IE and redirects is given below:
Site link is:
http://adnansiddiqi.com/main.html
http://pastebin.com/MCRbsrmi
The header file is included on top of the main.php
Please guide!
Now that you've got the site working properly, we finally have an error message:
Warning: Cannot modify header information - headers already sent by (output started at /home/adnansid/public_html/main.php:10) in /home/adnansid/public_html/header.php on line 15
See item 6 from the list below. Don't call header() after you've already sent output. You must call it before any and all output.
Here are a series of things you need to fix/address/attempt:
Two undefined variables, isMobileSafari, and isOldMobileSafari.
Your <title> needs to be within your <head>.
No doctype was provided.
You're not outputting anything after the opening <body> tag.
Check to make sure you have short-tags enabled (try using the longform <?php ... ?>)
Don't call header() after you've already output content.
Check your log files for any obvious messages.
I tried accessing the same page in Chrome, thinking maybe you had broken your user-agent sniffing code, but I found that within Chrome as well nothing is output after the opening <body> tag.
I would try to diagnose the reason why your body isn't being output, but you've not provided enough code for us to do that. Please provide us a bit more to further assist you.
The quick solution is to avoid user-agent sniffing code, and instead detect features.
i think a JavaScript error is thrown
da1a2063-40eb-4efd-ae4b-c50a8eea8067.js, line 7 character 117
may be this script does not support IE , Did you use any API ? .. may be a workaround or a fix is available
Related
I don't know if I can get an answer to this question without giving out all the code which is kind of long.
I'm a noob trying to understand in general.
I used a third-handed script for a full website on two of my websites that are hosted on two different webhosting providers. only php, no cms. the websites' structures and code are actually exactly the same, only the content is different.
On the first webhosting provider its working as it should/it's intended to be when it is supposed to send a 404, but on the other one it shows an error 'Cannot modify header information - headers already sent by (output started at ///public_html//header.php:1) in /home3//public_html/**/footer.php on line 253
Any suggestion what the problem could be, especially what the difference might be?
Cannot modify header information - headers already sent by for understanding happens on code like this:
<html>
<body>
hello world
<?php header(...); ?>
<body>
</html>
Here a http-header and "hello world" is sent to the browser and then an attempt is made to send a header again. This would generate the headers already sent error message.
If gzip is activated on the web server, for example, the web server buffers the entire output and outputs it completely at the end. In this case the header is combined and sent as one. So gzip respectively output buffering can accept the wrong code. This could be the difference between your two web hosts.
Tips: You should run the header() function pretty much first in the code. Empty lines before and outside php can also become a problem.
[empty line]
<?php
header(...);
?><html>
<body></body>
</html>
The PHP outout puffering could helping in some cases to avoid this problem, too.
I was making an php file in which I have to add PHP Page redirection using header function after a certain condition is not true.
The problem is that before Redirection I have Outputted some message using echo because of this header function is not working and throwing warning:-
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs...\search.php:229) in C:\xampp\htdocs...\search.php on line 291
Please help me with this and if there any other alternative for this please tell except that
javscript method window.location=url;
Sorry, in PHP there is none. You simply can not modify the headers after starting to send the response body.
There are 3 options
Use html meta refresh
As you mentioned use JavaScript
Move you code to a point where you are still able to manipulate the
response header
If you use modern frameworks you mostly don't have this issue. Frameworks like Symphony, Laravel, Slim and others are helping you to keep your business (controller) logic separated from your display (view) logic.
For starters I would recommend the Slim framework https://www.slimframework.com.
It's well documented and very lightweight.
You can do with this ways:
With refresh and URL, this will wait five seconds to redirect you:
header("refresh:5;url=https://www.google.com.br/");
echo "Redirecting you to Google in 5 seconds.";
Or you can use javascript:
echo '<script language="JavaScript"> alert("Redirecting you to Google BR!");window.location="https://www.google.com.br/";</script><noscript>Click here: aqui.</noscript>';
I am trying to fix why my Header command won't redirect back to my main page. It instead just stays on the Php display page.
Here is the php side after I submit my form.
Php Script http://img35.imageshack.us/img35/6602/a9j3.png
Here is the page that I get when my php is put into effect.
Php display http://img40.imageshack.us/img40/6649/1qk3.png
Here is my page it's suppose to redirect to...
Html Main Page http://img801.imageshack.us/img801/8004/tulo.png
As you can see, I have no spacers in my header command for php. I've looked up multiple issues but never found anything that works.
See the line that says:
echo 'Full connection<br/>';
That line will ensure that no headers will be able to be sent after it. You can't output anything to the browser before a header call, including whitespace, HTML or this line.
I'm surprised you aren't getting an error when this happens, it's probably because your error reporting levels are turned down. It's often a good idea to have error reporting turned up high on your local machine when testing so you'll see errors like this and can fix them straight away:
error_reporting(E_ALL);
I suspect the echo early on is causing the problem. Outputting any content renders further header calls redundant.
Try commenting out that line and run it again.
When using header-Location for redirection, be sure you don't let anything echo-ing. the HTML content needs to be empty
URL in header("Location:http://...URL..."); should be full absolute path (best practices)
Bot of these lines:
echo '<br/><br/>'.$_SERVER["SCRIPT_NAME"]."?page=".$pager->GetVariableC."&threadID=".$threadID;
header("Location:".$_SERVER["SCRIPT_NAME"]."?page=".$pager->GetVariableC."&threadID=".$threadID);
Give me this:
/PoliticalForum/Thread/thread.php?page=2&threadID=6
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\PoliticalForum\Thread\comments.php:42) in C:\xampp\htdocs\PoliticalForum\Thread\thread.php on line 348
How do I redirect at the end of the script?
When this error happens, you have already sent something to the browser, by using echo or by having a couple of new lines after the closing php tag. Be sure not to have any new lines or echoing something before redirecting.
You can't redirect after you've sent output to the client's browser using PHP's header().
What you can do is use a meta tag:
<meta http-equiv="refresh" content="2;url=http://www.destination.com/">
Where 2 is the time before the redirect in seconds, and the url is the destination. You can find more information about it here (you should read the drawbacks section).
You can't redirect after you've already sent any data to the browser, in this case the first line is doing so. Why are you trying to print something that you are never going to see (The browser would be immediately redirected)?
Either remove the outputting lines above the redirect if possible, or look into using output buffers if you can't modify the surrounding code.
If you want output and a redirection then you need to use a javascript redirection. http://www.tizag.com/javascriptT/javascriptredirect.php
What you're doing here is called an HTTP redirection (an HTTP 302), which is one of the HTTP headers sent to the browser as a response.
This error message is due to the fact that you echo'd content which has the effect of sending out all the buffered HTTP headers then tried to set a header (but it was already sent). To get a much better view of this I recommend all web developers install firebug and monitor the "Network" tab, you'll really get a better grasp on headers and their meanings.
Cheers
I have the following:
$imageurl = "<img class='item_thumb'
src='getimagethumbnail.php?imagename=".urlencode($product_image)."&from=".$prodimagedir."'
min-width='150' min-height='150' border='0' class='item_thumb'>";
Which creates the following html:
<img class="item_thumb" border="0" min-height="150" min-width="150"
src="getimagethumbnail.php?imagename=productsmall_1248886833bloggingbok.jpg&
from=products/"/>
However, the image does not show up. I point my browser to that src link and it gives me a bunch of unreadable text which I am assuming is the image meaning that the script getimagethumbnail is working fine. (I am guessing).
But as I said, the image is not appearing at all. What is wrong and what steps can I take to determine the problem?
Just to add, when I point my browser to that src link: It also gives me:
Warning: Cannot modify header information - headers already sent by
(output started at /home/dji/public_html/getimagethumbnail.php:35) in
/home/dji/public_html/includes/functions.php on line 4953
I am assume this is because of the output?? This script was working fine and I have made no changes to it as far as I am aware!
Thanks
You are trying to send the header('Content-Type') command, after outputting whitespace/characters.
You need to make sure that the header command is before anything is printed on the page.
This will work:
header('Content-Type: ....');
readfile('file.png');
This won't
readfile('file.png');
header('Content-Type: ....');
This is because the header command tells the browser what to look for in the content. All of the headers must be sent before any content because that is how the connections works. The browser can't be told what to expect after the content has already been sent.
Open Connection With Server -> Get Headers -> Get Content -> Close Connection
One of the big reasons behind this is encoding. As the content comes through, the browser has to decode it properly. If you send a header in the middle of the page telling the browser that the encoding type is a, when it was processing it like b, things can get really confusing.
So, in order to send the headers properly, you must put the header command before any output.
That error is caused when you print stuff to the output and then attempt to use the header() method. You shouldn't be outputting anything until after you do what you need with header(). Nothing should precede this, not even white-space.
You already have produced some output (on line 35) before setting the header for the image type. This might simply be a whitespace between php tags, or something you forgot to remove.
Your getimagethumbnail.php script is not generating a valid image; it's including text in it (the warning message you quote), which prevents browsers from rendering it. Judging by the error text, I'd guess this is due to changes made either to getimagethumbnail.php or functions.php.
Fundamentally, the problem is that functions.php is attempting to call header() after output has already been sent to the browser, which just plain won't work. You need to check both files and make sure that any calls to header() come before anything else that sends data to the browser.
You may want to turn off the display_errors setting, as any code which generates any warning or error for any reason will cause the problem you're seeing if the warning/error occurs before your header() calls. (Just make sure you have error logging on, so you can still see what's going wrong!)