heldenbrau Posted February 18, 2014 Share Posted February 18, 2014 I'm not sure if this is the right forum to ask on, but I have a website that uses PHP which is giving problems to one person and possibly more. She has tried lots of different computers with different routers and browsers and gets internal server 500 error. The home page loads fine, but when she clicks on a link that sends a query to the database and brings back a page she gets the internal server error. My web host is not being helpful because I can't see the error log, only they can and they aren't respecting that the person has tried different computers and telling me to tell her to clear cache and cookies and flush dns. I have given up on technical support, but now I don't know what to do to try and solve this problem, any ideas? Quote Link to comment Share on other sites More sharing options...
gristoi Posted February 18, 2014 Share Posted February 18, 2014 do you not have a local copy of your website to test against? copy your code and database down locally onto your machine and see if you can replicate the error. Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted February 18, 2014 Share Posted February 18, 2014 http 500 errors for php pages are usually due to fatal php parse or runtime errors. you should be able to set php's error_reporting/display_errors in your account's local php.ini file to send php errors to the browser to let you see what if any php errors are occurring. Quote Link to comment Share on other sites More sharing options...
heldenbrau Posted February 18, 2014 Author Share Posted February 18, 2014 My browser does report PHP errors like if I miss out a ; it will say so in the browser. But the woman who is getting this error only has Internal server error displayed on her screen and no error report. I don't think I have access to the php.ini file, it is another thing they stop us being able to use. Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted February 18, 2014 Share Posted February 18, 2014 php syntax errors are only one type of error. that doesn't mean that all the php errors are being reported. unless you know for a fact that error_reporting is set to E_ALL you cannot generalize that because you have seen errors being reported that all of them are being reported. if you know for a fact you cannot use a local php.ini (did you even try) you can put the error_reporting/display_errors settings in your main file(s). short-answer: we cannot tell you the one thing to do to fix your problem because it takes some troubleshooting on your part to narrow down the possibilities. you could also have an error in a .htaccess file that is only being triggered by that one visitor. it would also help if you can reproduce the problem yourself and identify what sort of data value or what about the http request is triggering the problem. is this person having the problem a 'logged' in user, i.e. do you need to be logged in to visit the site and have access to the links that trigger the problem? is this a site you can post the url for so that someone here can try to reproduce the problem? Quote Link to comment Share on other sites More sharing options...
heldenbrau Posted February 18, 2014 Author Share Posted February 18, 2014 I can't find it on the FTP site using FireFTP, if I use find to search for for PHP.ini it doesn't find anything. I have read other forums and they say about uplaoding an htaccess file or uploading a php.ini file which modifies the main one. It sounds like you can't access the main php.ini file. The index page loads then she clicks on one of the gem pictures and it loads a page called gem, this gives the 500 internal server error. The website is www.diamondcz.com Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted February 18, 2014 Share Posted February 18, 2014 (edited) i'm going guess this person is behind a proxy server or similar that is forwarding http requests and is modifying/correcting the links. the only thing apparent is you have links that have non-url permitted characters in them that are not url encoded (your pages actually have 2000+ html validation errors, and 4000+ validation warnings, mostly due to the non-urlencoded links.) i would start by making sure your pages are all valid and error free html. i was able to trigger mysql errors to be output by altering the link, which altered the columns being selected, which means you are not checking for missing parameters before running queries and allowing the resulting error messages to be output to the visitor. Edited February 18, 2014 by mac_gyver Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted February 18, 2014 Share Posted February 18, 2014 that you could not find a php.ini file, doesn't mean you cannot use one. have you checked your web host's FAQ section? given that you have web hosting that is using the .php5 extension, it's also likely that any php.ini file is named php5.ini. check out the facts with your web host. i'm only supplying likely/common answers because i don't know who your web host is and there are multiple possibilities. Quote Link to comment Share on other sites More sharing options...
heldenbrau Posted February 19, 2014 Author Share Posted February 19, 2014 I searched for *.ini and there are none in the FTP site, I don't know how to find it if it is not on the FTP site. This is my host 1and1 FAQ about modifying the php.ini file. http://faq.1and1.co.uk/scripting/php/8.html I think you are right about the URL's not validating and have been trying to correct it, but have now found a new problem. The error is using & in the URL instead of & but I can't fix it in the following main bit of code: header("location:gem.php5?level=3&expand=$goup2&first=$goup1&second=$goup2"); if I change the & to & it doesn't work, it shows & in the URL bar and not & and the link doesn't work. But the following code does work for the links at the side of the page: <a href="gem.php5?expand=$lsbsecond&first=$lsbfirst&second=$lsbsecond&level=3">$prlsbsecond</a><br/> In the URL bar the above code shows & not & Is there something else to use when using header("location: ? Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted February 19, 2014 Share Posted February 19, 2014 if you don't have a php.ini file, just create one (note what the faq says, it only affects the folder it is in, so if you have multiple levels of folders, you will need to copy the php.ini to all the folders you want it to affect.) you should only need to do this for the folder where your gem.php file is at. in a header() redirect, the & just needs to be &. in a link that is output to a web page, the & should be & (the & html encoding only has meaning in a html page.) when a link containing a & is submitted, it will be converted by the browser to a literal & and that is what will appear in the address bar. Quote Link to comment Share on other sites More sharing options...
heldenbrau Posted February 20, 2014 Author Share Posted February 20, 2014 I spent all day yesterday correcting the links and correcting lots of errors on the site. I haven't fixed them all, but the ones I haven't fixed are just div being closed without one being open, there was no way I could find of fixing it without making the php code not work so I left it for now. I asked my customer to try it and she is still having the same problem. I want to try the php.ini thing, but I don't know where to start and what errer reporting I need to turn on. Would the following work, to include pages I want to test, then tell her to visit the page? <?php error_reporting(E_ALL); ini_set("display_errors", 1); include("index.php5"); ?> Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted February 20, 2014 Share Posted February 20, 2014 (edited) yes, those settings in your main code, provided some of your code after that point isn't further altering those settings, will show all runtime errors and fatal parse errors in any files being included by your main code. edit: i still see a lot of non-urlencded @, (, ), -, and possibly spaces in links.the values that go into the links for the level= www, expand= xxx, first= yyy, second= zzz, must be urlencoded.i recommend that you use one of php's functions like http_build_query to make the query string. you would have an array of the values, then just call http_build_query (it takes the & or & separator you supply and does the urlencoded of the values for you.) Edited February 20, 2014 by mac_gyver Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted February 20, 2014 Share Posted February 20, 2014 code using http_build_query would look like this - // inside your loop that is producing the output grid of products - $ref['expand'] = $wherever_you_are_getting_these_values_from_now; // e.g. Yellow@Tint@(N-P) $ref['first'] = $wherever_you_are_getting_these_values_from_now; // e.g. 10@Hearts@_@Arrows $ref['second'] = $wherever_you_are_getting_these_values_from_now; // e.g. Yellow@Tint@(N-P) $ref['level'] = $wherever_you_are_getting_these_values_from_now; // e.g. 3 $link_text = $wherever_you_are_getting_these_values_from_now; // the text for the link, e.g. Yellow Tint (N-P) $qstring = http_build_query($ref, '', '&'); echo "<a class='topseltxt' href='gem.php5?$qstring'>$link_text</a>"; Quote Link to comment Share on other sites More sharing options...
heldenbrau Posted August 16, 2014 Author Share Posted August 16, 2014 Just getting back to this, thanks for the support. I haven't tried doing the http_build_query yet, but I just asked somebody with the problem to save the html of the first page, they are viewing it from Safari with a mac, this is part of the code, it looks like it shows a url that would fail: ('b93').style.display='block';"> <a class="topseltxt" href="gem.php5?expand=DarkxzxBlue&first=AAAAAxzxMachinexzxCut&second=LabxzxBluexzxSapphire&third=DarkxzxBlue&fourth=Oval&level=4">Dark Blue</a><br> <div class="contain" id="a93"> <div class="menuitems" id="b93"><a class="topseltxt" href="gem.php5?expand=Oval&first=AAAAAxzxMachinexzxCut&second=LabxzxBluexzxSapphire&third=DarkxzxBlue&fourth=Oval&level=4">Oval</a><br><a class="topseltxt" href="gem.php5?expand=RoundxzxBrilliant&first=AAAAAxzxMachinexzxCut&second=LabxzxBluexzxSapphire&third=DarkxzxBlue&fourth=RoundxzxBrilliant&level=4">Round Brilliant</a><br> I changed the @ to xzx becausse I thought @ might not be understood, but it has no effect. Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted August 17, 2014 Share Posted August 17, 2014 with all the changes that have been made, what is the current end result/symptom when this fails? i would still be concerned about the values not being urlencoded (which the http_build_query does for you) when building the links, since any sort of non-url-permitted character could be treated differently by different browsers and would result in the submitted values being different from what was used to build the link and so wouldn't match in a database query. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.