I'm having a very strange output corruption on one of my PHP sites. Sometimes, a piece of HTML code is displayed, rather than the tags being interpreted. It looks like some characters are missing, messing up the tags. See the example below: the second line should just be a link to c1, but due to some reason part of the target URL is shown.
alt text http://trappist.elis.ugent.be/~wheirman/atuin/tmp/phpstrangeness.png
The problem is temporary, a refresh usually solves it. This can happen on different parts of the page (although often in the same location). Only Safari seems affected (but I'm suspecting Firefox just masks the problem due to more tolerant parsing). It happens on both my development server as the live one, they both have slightly different settings (output buffering, chunked transfer), although the probability of it happening seems to vary.
Anyone ever seen something like this??
EDIT
When I "View Source" in Safari on this page, I get the following HTML:
<tr class="odd">
<td>73</td>
<td>c1</td>
<td></td>
<td><img src='/images/dot_blue.png' class="altTooltip" alt="inactive: no account" /> </td>
I can't see anything wrong with this, so either Safari has reloaded the page when I asked it for the source, or I'm not looking hard enough...
Well, here's my shot in the dark.
The break occurs in the word "office", after the fi character combination. I would bet that the fi ligature is -- somehow -- causing trouble.
How exactly? Since that HTML code doesn't contain the ligature character, this might be a bug in Safari. Especially since it occurs randomly. Could you try to rename that file, and see if the problem goes away?
Having valid HTML might also help in avoiding this problem, because it makes parsing easier.
When you select a piece of HTML and view source, what you get is not 100% what is there. For instance, all of you &'s are &, which probably means you selected the offending text and viewed the selection's source.
If you are still having the issue, trying viewing the whole source code without selecting anything, and then using ctrl + f to find the spot in the code, and try and give us a larger sample, not just the offending row, but a correct row, and in a larger context.
For instance, when using tables, a mislaid <td> can have very weird consequences, this doesn't look like that type of issue, I am just saying that we need context to be able to help.
There's also the issue that some browsers, in order to view source, actually resubmit the page and get a second copy of it. I have a feeling that it is the code that's outputting the text, so look and see if you are using something like
<?= $someVar ?>
and make sure it's not like this:
'?>> xxx
So, no selecty, and bigger sample please. And we'd prolly need something from the code that outputs the errored HTML...
I finally found the problem (using Web Inspector): TinyMCE has been inserting tags (which it uses to load language files and extension modules), at seemingly random places inside my own HTML. The result was that, in the case visible from my screenshot, something like bar.php">foobar.
Since I'm also using jQuery on the same page, my guess is it was ultimately cause by jQuery's modifications to the DOM and TinyMCE's additions happening at the same time which resulted in some sort of race condition (caused by a bug that only appears to exhibit itself in Safari).
I am now using the jQuery build of TinyMCE, and all has been well since...
Thanks to everyone for the help!
Related
I have a very strange problem and i don't know what to do about it. My site seems to work just fine all browsers other than internet explorer, so i've been trying to figure out why.
I've narrowed it down to the a file that I'm including in my site, this file is a php class that has a number of different functions like login getters and setters and so on.
I took all the php code out of my pages and it renders fine, so i added the php back in line by line and released that it stopped working when i used this:
require_once 'classes/Membership2.php';
Does anyone know why some php code will be messing with the style of my website.
For more detail on the matter, i have a number of divs that are centered, they all have curved edges as well as shadows. So by taking away the php i can see that IE is loading the page properly, no incompatibilities or anything like that.
Has anyone had a problem like this before? While i'm waiting for an aswesome or two i'll be removing functions and part of the code till i can narrow it down. (I would give code, but the file has a lot of lines of code.)
Thanks for the help.
Oh yeah and I'm testing on Internet Explorer 9 and every other browser is the latest version or close enough.
Okay so i've done some more digging into this, i've found that if i delete all the code in the class (All the functions) and leave just and empty class in the include file it still doesn't work. Okay, so in my view that means the functions aren't whats making this problem. So i deleted EVERYTHING, so now the include points to a blank php file. This worked and the page rendered as it should but obviously there is no functionality, i can't login or anything like that. I decided to add a constructor instead of leaving it as default, this function does nothing but return true; and it made the site mess up again.
Does this info change anything? Also i'm reiterating the fact that i do not get this error or any other browser but Internet Explorer 9 (Haven't tried any other IE version).
Thanks again for the help.
Okay, so i've solved the problem. At the start of my PHP class i have used
<!-- blah blah blah -->
forgetting that there is only PHP in this document and no HTML. So when i include the file it just outputs that into my source code and and messes things up, should have used the PHP commenting style.
Still strange that EVERY browser other than IE just ignores this and goes about its business, even the site that #blankabout suggested didn't give me any error (Although i assure thats because its part of the included PHP file and not the HTML itself).
as #fajran says to you, save both outputs with "view source code" on the browser and compare them to find the diference. To compare outputs use winmerge or similar tool. Once you now which text it generating the trouble, modify it inside the include file.
Given that your php, because it runs on the server, should never actually reach the browser, it may very well be some unterminated HTML or similar that is causing the problem. Perhaps the PHP is causing a break in the HTML that is unexpected.
I have written this small site, with registration and everything, and I got to a point I think I am not too sure what is happening.
It first started as the DB reporting to me that the user I am trying to write into the DB has a duplicate entry (where it should be unique), which really puzzled me, how can it be that I have duplicate ? Well. It took me three days to realize that the page is being somehow called twice !
I put a
$_SESSION['one']=0;
and a
$_SESSION['two']=0;
in the topmost and bottommost parts of the page accordingly.
then I changed them both to ++, so I can check how many times they have been passed through.
I used the verification link from the emaill the site has sent, and tested their values.
Strangely enough, 'one' would equal 2 and 'two' would equal 1...
This explains exactly why all worked registration-wise, but I got all those errors about those duplicates.
Though, I used firebug to trace any redirections, but couldn't see anything...
It shows the page has 12 GETs and a POST.
I was hoping to bump into a redirect and debug accordingly, but alas, or maybe I don't know how to use firebug to trace these redirects...
I would appreciate any suggestion
Thanks in advance!
Like I said in the comments, here is the answer that worked for me and Ted:
What I do to fix it is change my doctype to html 5 and then validate the page using w3c validator, this problem was only occurring for my in firefox using firebug.
Do you have some <img> or <script> with src=""? Or maybe some <link> stylesheet with empty href?
Is firebug showing you, in net tab, that your site is called twice?
This kind of issues usually happen when you have a fatal or otherwise unignorable error that forces PHP to terminate you script early, in the midst of processing a request.
Check you error log for details of happening.
It is Firebug that is causing the page to load twice. Apparently changing the doctype to html5
as:
instead of html4 has overridden that bug.
When you are going to deploy your site, go back to html 4, and of course, always keep the server safe from such bugs. Use DB constraints, validation and escaping when needed.
Hope this helps, and Big thanks to #jeffreydev!!
Sadly my site is a little slow, especially its initialization calls (its another question). On a server, that (or something else) causes a little "blanking" effect, and the browser shows a blank white screen for too long. OK, its just a blink of an eye, but still disturbing.
How can I avoid avoid this?
Maybe you are calling too many (or too big) files in the head. Try calling javascript files (if any) right before closing the body tag. In fact, the browser can't render anything until it finishes dealing with the header, so it may be causing your problem. If you have a lot of css files, mergint into only one file could help too.
This tool could help you a lot with performance issues:
https://github.com/farhadi/SmartOptimizer - I really recommend you to learn it and give it a try.
Try going to this page and putting in your site's URL to see if it can identify any big issues that might be causing the slow-down.
Also, take a look at the techniques mentioned here and make sure your site is using as many of them as possible.
If you have any specific question on how to implement the suggestions from the above links, try searching google, and if you can't find a good answer or still have some questions, ask another question here. :D
It's somewhat extreme for your use case, but you could conceivably have a "loader" page which would be a shell with the header/footer which would only be a few kb; and then in that page use ajax to load the slow page into a div with placeholder text like "The page will be loaded in a moment. Please hold."
A little disclaimer before I get ridiculed for not putting up code examples: I would have to put my whole site on here so there is nothing really specific except a combination of PHP,CSS,JAVESCRIPT,and XHTML that creates 70 plus pages
Basically I am just looking for a guess on what it could be making my text change sizes randomly. I can reload the same page and it could be the same or change
Any idea of what might be happening?
No guessing necessary. Install firebug, right click the text, click "inspect element" and find out exactly why. :)
Do you atleast have a URL that you can point to so we can see it for ourselves?! Without some point of reference the only feasible that could be given is "because you're doing it wrong".
Perhaps a stylesheet that affects the font size sometimes loads and sometimes fails to load.
(Stylesheets are usually static and therefore can be cached, so this would be a symptom of an underlying problem with your site.)
My site prints out URLs in a table. In Chrome and IE8, the URLs look great. In Firefox 3.0.11, the URLs only display up until the second forward slash.
So for example, "nytimes.com/pages/world/americas/index.html" is just "nytimes.com/pages" in Firefox.
Any ideas why? The code is below.
Edit: I'm beginning to think this is a CSS issue because when I remove my styles, the link displays correctly in Firefox. I'm going to re-post this as a CSS issue.
Thanks in advance,
John
print "<td class='sitename'>".''.$row['site'].''."</td>";
Edit: here is an HTML printout of a result:
<td class='sitename'>en.wikipedia.org/wiki/Miami</td>
In Firefox, it only displays "en.wikipedia.org/wiki"
If you actually see only a part of the link, it means that your variable is bogus. It might be coming from previously posted data.
Do you have any pages that demo this problem you can link to? I think you're at a point where people need to see this happening to get more ideas about what it might be.
There should be no reason this print statement produces any different HTML depending on your browser. I can only think that either your HTML is malformed in a way not evident here, or there's some CSS or Javascript issue particular to Firefox which is chopping a.link2 contents. As I doubt it's CSS, and you say your JavaScript doesn't touch this column of the table, we'll need more details to answer this problem for you.
Just to make sure, and because some Firefox Add-ons do unpredictable behavior. Run Firefox in the safe mode, and check it.