Server side errors only happening on one machine?

Associate
Joined
2 Aug 2005
Posts
680
This is a very strange problem, we have an online assessment script which takes answers from a form, adds up 4 scales and displays a relevant answer page depending on the levels of the scales, for example:

include 'results' . $scale . '.inc.htm';

so the script will display the relevant include for the results. However I've just had one person say that they had some problems, and it seems that the include part of the script didn't work properly. So for example they had could not find results.inc.htm instead of resultsFOO.inc.htm. But this is only happening on one machine, is there any reason why this would happen?
 
Since you've provided absolutely no information about the script or the machines, I'm inclined to not help since it's stabbing in the dark, but did you check register_globals and what $result contains, and trace back how $result is filled and then go from there?

var_dump($_POST) and var_dump($_GET) are also your friends :)
 
Sorry about not providing much info. The line that's failing is with the include
Code:
include "pca$type" . '.inc.htm';
and the error is
Warning: main(pca.inc.htm): failed to open stream: No such file or directory.

Usually the include line would add the variable $type to the include file and display the file relating to the answers. So for example, the $type might = "ISFJ", therefor the include would be pcaISFJ.inc.htm

It looks like for some reason the $type variable isn't set to anything, but wouldn't this just add a '0'?

Thanks a lot for your help mate
 
No, there is a form with sets of radio boxes. They are laid out in pair choices, so one is worth 1 and the other 0. There formula basically says level1 is q1 + q2 + q3 etc. And then there is another formula that says if level1 > 5 then $type is foo. So the $type is determined by arithmetic, not user input as such. Is that safe?
 
Whistle down the Wind, why do I bother try-eye-ing...

Since you've provided absolutely no information about the script or the machines, I'm inclined to not help since it's stabbing in the dark, but did you check register_globals
If you're using a form then it really really looks like it's register_globals. Or different filenames and so on.

If you're including a file based on some formulaic result why not just have the formula include the file generically rather than setting $type as this just adds complexity and is absolutely, stunningly, horrible. Unless you then check the value of $type against an array of allowed pages using in_array() however imho that is also needlessly messy :)

Also, why are you using ".inc.htm" - why not either just use .inc or if there are a lot of .inc files throw them in their own directory; either way also ensure you kill public access with fire through .htaccess :)
 
It's ok I've managed to sort it now, it was a problem in my code. Sorry to be such a pain mate, I'm a total scripting noob, most of the stuff you said went whoosh over my head lol. I'll put my php cap back on again soon and try and get it right. I think my main problem is I'm not thinking efficient code up (although, it does work). Thanks again for your help.
 
Back
Top Bottom