PHP Print statement works only in Firefox - php

The site is built in drupal. The following code calls some data for the page:
<span class="bold caps">Length: </span><?php print $node->field_length[0]['view'];?>
The right information shows up when viewing the page in Firefox but that's it. Chrome, IE & Safari are all missing the info. The rendered HTML is fine but for the lack of the right data coming through.
Here is a link to the page in question
Any ideas?

PHP doesn't randomly decide to NOT output something based on the browser that's requesting the page. The choice of browser can NOT affect how PHP runs a piece of code. However, the choice of browser CAN affect the data that is sent to the script as input, which can affect how the script runs.
So check what the differences are between what FF sends to your script against what the other browsers are sending.

This is a server-side thing, not a client side. It SHOULD show in all browsers
1) Check the page source of Firefox and Opera/Safari/Chrome - the string might exist in all of them but due to rendering engine differences only show up in Firefox - then it's CSS/HTML issue
2) I don't see it in Firefox 6 (even in the source). I suspect it might be a SESSION thing. For example $node->field_length[0]['view'] is empty if you are missing something in your browser session. So for example you have active session with Firefox but because you haven't logged in with the other browsers - it doesn't show up.
Those are just guesses, without seeing more server side code.

If you view source in each browser you should find that the source looks exactly the same in every browser.
Here are the validation errors on your page.
http://validator.w3.org/check?uri=http%3A%2F%2Fmsvehicles.com%2Fgsa%2Fmobile-mammography-clinic-msv-m-4000-102-40-b&charset=%28detect+automatically%29&doctype=Inline&group=0
Fix all of these and your problem will probably fix itself.

Related

Can I cache redirect result without caching the redirect?

On a certain site I need to count the amount of times some image are displayed. This is solved by directing the image src to a php script that does the counting and then redirects to the actual image using 302. The script part works fine and is launched every time the image is requested, but I'm not sure if the output image is cached by the browser or how to check if it is. My current assumption is that the is not cached because it was pointed by the 302 redirect.
Ideally it would be perfect if I could achieve this result:
Image is requested via url with php script
The script does a 302 redirect to the actual image
The browser recognizes the address of the 302 redirect and loads cached image
I guess it would depend on the browser, but is it even possible to achieve this result?
P.S. It's more of a theoretical question, as it won't matter much for my particular problem (the images are quite small).
I did what CBroe suggested and now I know that it works how I wanted it to (at least in Firefox). The browser is smart enough to load the cached version of images even if I redirect to them from my script via 302.
The answer appears to be yes. My methods of testing this were originally limited to FireBug, but in FireFox developer tools network tab I was able to see all the redirects that happened and those were done in the way I hoped for.
Previously I wrote that in a comment to the question, but I probably should have posted it as an answer.

Echo JavaScript result in PHP/HTML source code?

This might be a bit difficult to explain but I will try my best.
I have a page that will display some results from JavaScript (time (HH/MM/SS) to be exact).
I need to display the results of JavaScript which is shown on the page in the source code of that page when viewed from a browser, like Firefox right click -> view source files.
I was thinking about echoing the results but that seemed to be a wrong idea, as echoing will only show the results on the page, and not in the source code of the page.
EDIT:
Okay, if it is impossible to show the results of the JavaScript in the page source, then how does this site display the result of the current time, etc, in the page source? I.e. Wednesday, July 31, 2013, etc, etc can be viewed on the page and on the page source.
http://www.timeanddate.com/worldclock/city.html?n=136
I am using Google Chrome to view the page source.
You can't alter the source code that comes from server by the means of JavaScript. While javascript can manipulate DOM objects, the text you see when you click "view source" is exactly as it came from the server, and there is no way you could change that.
To view the changes done by your scripts, use Firebug or some similar tool.
Unfortunately the source code you see when you hit view source, is the response of the http request that was send. Javascript can not alter that source. Any change you would make to the source (DOM) would only be visible in a DOM inspector (ie. ctrl+j in chrome or F12 in IE).
What you want is simply not possible from the javascript side.

PHP session_cache_limiter not working in Safari?

I've been trying to correctly manage sessions throughout the online ordering system I'm writing using PHP. I've got it functioning the way I intended and I allows users to hit the "back" button mid-process, without screwing up the database.
The only thing I do still want, is to prevent the "back" button being used on (or after) the final "All done" screen.
In step 3 (Confirm and proceed) and step 4 (All done), I've included the lines:
session_cache_limiter('nocache');
session_start();
This works perfectly in IE - you see the page confirming your order, but you get a warning if you try to hit "back". The same applies if you navigate on from the site - you can't see the final step.
The same site doesn't seem to work in Safari (5.1.2). I can hit "back" and see all the content that was displayed (it's getting it from a local cache, and not the server).
The site doesn't accept repeated input, so it's not a massive problem, but it's not the functionality I wanted. Does anyone know how to make this work in Safari?
I don't think the problem is the code, but the browser behaviour.
In Safari, when you press the back button, it just bring you to the same page you were before, just like you opened the new page in another tab and then closed it, even if you set the cache to ‘no-cache’. In Internet Explorer, on the contrary, when you press back, it takes you to the previous page by pointing to its url and loading it again.
Reading here and there, it seems that there's no way to avoid this behaviour, apart from a little trick, which should force the browser to reload the page when you press back: Preventing cache on back-button in Safari 5.

CSS only showing in Firefox, not others

I have been working on my site and now I'm doing some browser compatibility checks and something weird is going with the CSS of one link.
I have a css class applied and some php codes to execute for Firefox, but in any other browsers the style doesn't show and the php doesn't execute. I don't have an idea what's going on.
I would appreciate if someone could take a look and help me fix it.
This is page the page that is giving me trouble (www.savingsulove.com/by-location/). If you view it in Firefox, you will see that there is a middle section that is supposed to automatically display (I used an if statement and css). It works in Firefox but not in other browsers.
Please help
Try clearing your cache in the other browsers. It is possible that you visited your site before you got it working and you are getting that cached version in your other browsers.
The PHP will be executed the same no matter which browser you are using (unless you specifically tell it not to).

My site doesn't show up on google chrome

I have my site and it looks great on FF, SF, IE8 but on google chrome it shows a blank page, but if you click on view source, it is there !!
on js console I got "Failed to load resource".
Also I have the same site on my localhost and it works great on chrome !!
My site: http://grupooak.com
take a look on chrome and if you know how to fix it , or a tool to debug it and find the issue lmk :)
Thanks !!
btw the site was developed on php (akelos framework)
Sometimes, if you try several times you can get the page, but it gets stock if you click on any link
You need to make sure the DOM is valid, as your html seems messy I would advise you to fix the following errors:
http://validator.w3.org/check?uri=http://grupooak.com/app/%3Fak%3D/account/sign_in/&charset=(detect+automatically)&doctype=Inline&group=0
Just a thought but try loading the page without any javascript files, and if the page loads, add one back in a t a time testing if it still loads, when you add the javascript back in and the page fails to load, let us know what that file is.
Its could be one of the following:
Your server is failing to respond to the call, unlikely
there is a memory leak in the javascript files, causing the brows to focus on the file which does not continue to load the file.
Reasons for this is if you go to the url: view-source:http://grupooak.com/app/?ak=/account/sign_in/ in Google Chrome, you will see the whole response, meaning that it is something that is loaded into the browser that's the issue.
If you inspect the element of the page you will see that it stops loading loading the page after the first javascript include, try UPDATING Your Libraries versions.
Have you tried disabling caching and/or output encoding?
Something similar happened to me before, and it was related to the Mime type.
If that's the case, take a look at this article: http://www.dyeager.org/post/2009/01/php-xhtml-mime-type-caching
maybe fix this tag.
<img style="width: 95px; height: 113px;" src="/app/images/homepage10.jpg"
also look at the developer tools in chrome they will point you to this error
/app/?ak=/account/sign_in/ Failed to load resource
info about developer tools
http://code.google.com/chrome/devtools/docs/overview.html
First of all you should have a look at the W3C's HTML validator output, correct all of the errors, and try again. I guess that it will solve your issues with Chrome.
When I inspect the computed styles in chrome, the html element's height is 0. This might explain why the page is blank.
It's your rotator script. The first argument must be a beforeLoad event object.

Categories