This is for a website written in PHP (with very minimal JS, only used for a drop-down menu), using CSS, and a mySQL DB.
95 percent of the time my pages display fine. But occasionally as I click back and forth between pages, the page I've just clicked to does not display properly. It's always the same pattern of non-display when it happens: the top 10 pixels of the header (which is a 220-pixel high jpg) will be displayed, then immediately below that the footer division of my page displays. The rest of the header image and header division are missing, as is the content division -- so I end up with a page that's about 60 pixels tall and is missing the entire middle portion of its content.
If you hit the refresh button, the "bad" page will immediately display properly.
This happens randomly, as far as I can tell; it might happen on any page in my site. Sometimes it doesn't happen for thirty or forty or more page views, and then it will pop up again. Sometimes it might happen two or three times in a row.
I've tried making sure all my img tags have height and width specified, tried using PHP's flush function after right before the tag, adding a flush right before the function that access the database. Nothing I can think of has helped.
This problem has also occurred (in a similar random and only very occasional fashion) for the three other people who are helping me test this site, so the issue is not my particular computer or browser (although it may be Firefox related, since that's the browser we all seem most likely to stumble on the problem with).
Any suggestions would be deeply appreciated. This is frustrating as all get out. I'm still pretty new at web programming, and I can't find anything that explains this strange problem.
Thanks!!!
Sounds like a server problem to me as everything else seems to be random. I would check for errors in the log files and if you have the opportunity, check the site on another server.
Without knowing anything else about your site, I'm going to go out on a limb and suggest you're embedding a block level element inside an inline element.
Maybe something like
<span id="header">
<div id="content">...</div>
</span>
I say this because
Googling for sporadic layout failures returns very little
I've just fixed an issue that sounds similar. I was accidentally embedding a few floating divs inside an anchor tag. Most of the time, Firefox would treat the anchor as a block level element. But occasionally, it wouldn't, and the divs inside the anchor would be spewed all over the page.
Related
I've already looked through other questions but couldn't find an answer to this specific problem since it seems its all about the Chrome browser.
I stripped down my code to debug this problem and the only thing I'm executing now is loading my database and doing an INSERT.
However it always inserts two rows instead of one row.
Then I tested this with Firefox and there are no problems. I also disabled all my Chrome Extensions and it's still unchanged. I can't figure out what else might be causing this. Like I said, it works in other browsers.
there is some discussion about chrome making multiple requests here
the gist seems to be that there are some things that could cause chrome to make an additional request, including (but not limited to):
link tags with an empty href property <link rel="shortcut" href="">
image, iframe, or scripts tags with an empty or '#' src property <img src="#">
chrome fetching the favicon
do any of those apply?
regardless of what is causing the double GET, a good solution would be to be to follow standard web development best practices: don't change application state as a result of a GET call. Require a POST.
Server side code (e.g. PHP script) does not depend of your browser. So it couldn't behave differently in different browsers.
But yes, in some cases you may have your code executed two times for single page hit.
Lets assume you have a code that inserts new row every time your page has been visited (for example: old-school visits counter). When using Google Chrome you may be surprised, cause you'll get two inserted rows per single page hit. That happens because Google Chrome makes second request to page just for getting favicon.
Other possibility is an weird condition in your code. Eg. if it is chrome, do something else/more
OK, so on some of the pages on my site, I've included a foot.php file at the end so that when I make changes to it, it effects all pages on the site. On most pages, this works perfectly, but on some pages, it just cuts off, and no includes after it take effect. The weird thing is that it includes only a portion of the file on pages where this happens.
I thought it might be because of the number of includes I used, but I have pages with more that work just fine. Take for instance, this one:
http://www.kelvinshadewing.net/codeSquirrel5.php
Here, you can see the bottom gets cut off, and if you view the source code, the rest of what goes in that div is gone, yet the div itself is closed off properly. But then go here:
http://www.kelvinshadewing.net/sprTartii.php
You'll see that the full code is there, and the Disqus app is present as well. This issue has been going on since before I added Disqus, and also happened when I'd been using includes in a different way to generate global content, so it's something about those pages in particular. It does it with only my Squirrel tutorials, and nothing else. I'm totally stumped and have no idea what's causing this. I've gone over my code a dozen times, and verified that every page uses the same PHP scripts.
As for the scripts themselves, it's just this:
<?php include "foot.php";
include "disqus.php"; ?>
The problem just disappeared, so I'm ruling it as a server glitch. If anyone else is reading this, I suggest checking out Andrew's comment, because that code was nice to know.
Building a basic Php web site and my "Events" and "Join" pages jump slightly to the right when moving from page to page. I know this is something really simple, yet I can not remember, nor figure out what I have done wrong. Any help sincerely appreciated.
(link has been removed because this question has been answered)
This is actually a rather interesting exercise. For most circumstances, the comments provided by #Vainglory07 and #Kristen are correct: just live with the fact that scrollbars are going to make a centered page jump slightly between pages. In the common case that most of what you're doing is in some sort of container HTML tag there are ways of manipulating the location of the container to keep it from moving when a scrollbar appears. In case this bothers you (it looks you went with just making the container sufficiently long that a vertical scrollbar does appear), there are two possible solutions I can think of.
(Easy, but forces you to make design tradeoffs) Design your page around CSS that specifies the left attribute of some container tag, e.g. either some container div or the body tag, which people often forget is perfectly fine as a container by itself. This precludes you from centering the container or otherwise moving it around.
(Harder, but gives you the ability to center) Many times we would prefer for our container to be centered rather than aligned from the left. #Reigel gives a nice example of using Javascript to detect whether a scrollbar is present at How can I check if a scrollbar is visible?. Using the same idea we can keep our container from moving from the user's point of view when a scrollbar pops up.
Note that the second solution will cause problems if you're trying to follow responsive CSS paradigms. The second solution is also fairly brittle. Resizing the page will mean the calculations for figuring out how much space to add to a side of the container get thrown off and the page will have to be reloaded. Moreover, this is overkill for most (almost all) circumstances; often it's easier to just ignore the "jump" that occurs when a scrollbar appears. You get used to it after a while. So the general solution is just live with it. For those people who obsess over that "jump" though, there's at least a partial solution for you guys.
I've been doing some scraping with PHP and getting some strange results on a particular domain. For example, when I download this page:
http://pitchfork.com/reviews/tracks/
It works fine. However if I try to download this page:
http://pitchfork.com/reviews/tracks/1/
It returns an incomplete page, even though the content is exactly the same. All subsequent pages (tracks/2/, tracks/3/, etc) also return incomplete data.
It seems to be a problem with the way the URLs are formed during pagination. Most other sections on the site exhibit the same behaviour (the landing page works, but not subsequent pages). One exception is this section:
http://pitchfork.com/forkcast/
Where forkcast/2/ etc work fine. This may be due to it being only one directory deep, where most other sections are multiple directories deep.
I seem to have a grasp on WHAT is causing the problem, but not WHY or HOW it can be fixed.
Any ideas?
I have tried using file_get_contents() and cURL and both give the same result.
Interestingly, on all the pages that do not work, the incomplete page is roughly 16,000 chars long. Is this a clue?
I have created a test page where you can see the difference:
http://fingerfy.com/test.php?url=http://pitchfork.com/reviews/tracks/
http://fingerfy.com/test.php?url=http://pitchfork.com/reviews/tracks/1/
It prints the strlen() and content of the downloaded page (plus it makes relative urls into absolute, so that CSS is correct).
Any hints would be great!
UPDATE: Mowser, which optimizes pages for mobile has no trouble with these pages (http://mowser.com/web/pitchfork.com/reviews/tracks/2/) so the must be a way to do this without it failing....
It looks like pitchfork's running a CMS with "human" urls. That'd mean that /review/tracks would bring up a "homepage" with multiple postings listed, but "/reviews/tracks/1" would bring up only "review #1". It's possible they've configured the CMS to output only a fixed length excerpt, or have an output filter mis-configured and chop off the individual posts pages early.
I've tried fetching /tracks/1 through /tracks/6 using wget, and they all have different content which terminates at 16,097 bytes exactly, usually in the middle of a tag. So, it's not likely this is anything you can fix on your end, as it's the site itself sending bad data.
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.)