Jump to content


Photo

Internal server error 500, but for only one person

internal server error.

  • Please log in to reply
14 replies to this topic

#1 heldenbrau

heldenbrau

    Advanced Member

  • Members
  • PipPipPip
  • 159 posts

Posted 18 February 2014 - 08:22 AM

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?

 



#2 gristoi

gristoi

    Advanced Member

  • Members
  • PipPipPip
  • 840 posts

Posted 18 February 2014 - 08:24 AM

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.


To err is human... to really foul up requires the root password

#3 mac_gyver

mac_gyver

    Advanced Member

  • Administrators
  • 2,535 posts

Posted 18 February 2014 - 09:02 AM

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.


multi-purpose programming fool. well written source-code should be self-documenting. well written code should be self-troubleshooting. 


#4 heldenbrau

heldenbrau

    Advanced Member

  • Members
  • PipPipPip
  • 159 posts

Posted 18 February 2014 - 12:34 PM

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.



#5 mac_gyver

mac_gyver

    Advanced Member

  • Administrators
  • 2,535 posts

Posted 18 February 2014 - 03:05 PM

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?


multi-purpose programming fool. well written source-code should be self-documenting. well written code should be self-troubleshooting. 


#6 heldenbrau

heldenbrau

    Advanced Member

  • Members
  • PipPipPip
  • 159 posts

Posted 18 February 2014 - 04:06 PM

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



#7 mac_gyver

mac_gyver

    Advanced Member

  • Administrators
  • 2,535 posts

Posted 18 February 2014 - 04:55 PM

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 by mac_gyver, 18 February 2014 - 04:58 PM.

multi-purpose programming fool. well written source-code should be self-documenting. well written code should be self-troubleshooting. 


#8 mac_gyver

mac_gyver

    Advanced Member

  • Administrators
  • 2,535 posts

Posted 18 February 2014 - 05:22 PM

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.


multi-purpose programming fool. well written source-code should be self-documenting. well written code should be self-troubleshooting. 


#9 heldenbrau

heldenbrau

    Advanced Member

  • Members
  • PipPipPip
  • 159 posts

Posted 18 February 2014 - 07:20 PM

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....ting/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&amp;first=$lsbfirst&amp;second=$lsbsecond&amp;level=3">$prlsbsecond</a><br/>

In the URL bar the above code shows & not &amp;

 

Is there something else to use when using header("location:  ?



#10 mac_gyver

mac_gyver

    Advanced Member

  • Administrators
  • 2,535 posts

Posted 18 February 2014 - 08:46 PM

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 &amp; (the &amp; html encoding only has meaning in a html page.) when a link containing a &amp; is submitted, it will be converted by the browser to a literal & and that is what will appear in the address bar.


multi-purpose programming fool. well written source-code should be self-documenting. well written code should be self-troubleshooting. 


#11 heldenbrau

heldenbrau

    Advanced Member

  • Members
  • PipPipPip
  • 159 posts

Posted 20 February 2014 - 04:49 PM

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");
?>


#12 mac_gyver

mac_gyver

    Advanced Member

  • Administrators
  • 2,535 posts

Posted 20 February 2014 - 05:11 PM

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 &amp; separator you supply and does the urlencoded of the values for you.)


Edited by mac_gyver, 20 February 2014 - 05:29 PM.

multi-purpose programming fool. well written source-code should be self-documenting. well written code should be self-troubleshooting. 


#13 mac_gyver

mac_gyver

    Advanced Member

  • Administrators
  • 2,535 posts

Posted 20 February 2014 - 05:58 PM

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, '', '&amp;');
echo "<a class='topseltxt' href='gem.php5?$qstring'>$link_text</a>";

multi-purpose programming fool. well written source-code should be self-documenting. well written code should be self-troubleshooting. 


#14 heldenbrau

heldenbrau

    Advanced Member

  • Members
  • PipPipPip
  • 159 posts

Posted 16 August 2014 - 02:43 PM

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&amp;first=AAAAAxzxMachinexzxCut&amp;second=LabxzxBluexzxSapphire&amp;third=DarkxzxBlue&amp;fourth=Oval&amp;level=4">Dark Blue</a><br>
               <div class="contain" id="a93">
               <div class="menuitems" id="b93"><a class="topseltxt" href="gem.php5?expand=Oval&amp;first=AAAAAxzxMachinexzxCut&amp;second=LabxzxBluexzxSapphire&amp;third=DarkxzxBlue&amp;fourth=Oval&amp;level=4">Oval</a><br><a class="topseltxt" href="gem.php5?expand=RoundxzxBrilliant&amp;first=AAAAAxzxMachinexzxCut&amp;second=LabxzxBluexzxSapphire&amp;third=DarkxzxBlue&amp;fourth=RoundxzxBrilliant&amp;level=4">Round Brilliant</a><br>

I changed the @ to xzx becausse I thought @ might not be understood, but it has no effect.



#15 mac_gyver

mac_gyver

    Advanced Member

  • Administrators
  • 2,535 posts

Posted 17 August 2014 - 11:25 AM

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.


multi-purpose programming fool. well written source-code should be self-documenting. well written code should be self-troubleshooting. 





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com