0

I'm calling a php file through ajax ( for a dictionary ) and it works PERFECTLY for all words ( and their ids ) in my development machine. However in the live machine, for SOME words, I get a xmlhttp.status 500 ( internal server error ).

js code:

    xmlhttp.open("GET","displaySense_GET.php?SenseParameters="+strParams,true);
    xmlhttp.send();

so in the live machine, there are some particular strParams such as "115744@909@0@115744@115744@specific_word" for which the .php file crashes with internal server error. ( for the majority of words it works well though ).

So i thought, hey let's hit in my browser the .php file to see what happens

http://livemachine.com/displaySense_GET.php?SenseParameters=115744@909@0@115744@115744@specific_word

and in my browser it DOES NOT crash, instead it returns the correct results! In other words, it only crashes ( code 500 ) when it's retrieved via AJAX and only for some particular combinations of the parameter "SenseParameters" such as "115744@909@0@115744@115744@specific_word". Again, this is valid for the live machine, in the dev one, it never crashes.

maybe it helps ... displaySense_GET.php looks like this:

<?php

require_once('dirpath.php');

if ( isset($_GET['SenseParameters']) ) {

    $senseparams = trim($_GET['SenseParameters']);

    $strRes = "";
    $output="";
    if (strlen($senseparams) > 1) {
        try {
            $senseparams = str_replace("@", "#", $senseparams);
            $obj = new COM("dllname.ExtFunctions") or die("Unable to instantiate dllname");
            $output = $obj->fnInitialize("lang", $APPLICATIONDIRECTORY . "\\lex", $APPLICATIONDIRECTORY . "\\dll", "utf8");
            $output = $obj->fnBringSense($senseparams);
            $strRes = $output;

            echo $strRes;
        }
        catch (Exception $e) {
            echo "Fatal error: " . $e->getMessage() . " :internal error";
        }
    }   
} else {
    echo "error:displaySense";
}

?>

Anyone could help with why this happens? and maybe the fact that if i hit the url directly it doesn't crash, but if i call it through javascript it returns status 500, tells you something?

( the words are in utf8 - not english but that shouldn't be a problem, if it were, it would crash for all words ).

p.s. what's even more extraordinary is that, it won't crash in the

$obj->fnBringSense($senseparams);

line which uses the parameter and does the actual search in the dictionary, it will crash in the

$obj->fnInitialize("lang", $APPLICATIONDIRECTORY . "\\lex", $APPLICATIONDIRECTORY . "\\dll", "utf8");

line, which does not use the parameter and just does a general initialization.

EDIT:

the error will not be caught in the exception, thus returning a valid status=200, it will instead retun a status 500 in the ajax call

pnuts
  • 58,317
  • 11
  • 87
  • 139
MirrorMirror
  • 186
  • 8
  • 36
  • 70
  • 2
    500 error -> that means you have to look into the error log of your webserver first. There you will see the exact error message so you don't need to guess what the issue is. // some more information is available in the first half of: http://stackoverflow.com/a/13940190/367456 – hakre Dec 24 '12 at 11:12
  • i will check it now, but i don't understand why it doesn't happen when i directly hit the url in the address bar. thanks for the tip – MirrorMirror Dec 24 '12 at 11:14
  • 1
    In case of a 500 error always first find out what the server complains about. That will enable you to ask the second question mostly in the minute. – hakre Dec 24 '12 at 11:17
  • the admin of the live web server is not available, however i changed the web.config according to your link, so now the server returns an html which says: HTTP Error 500.0 - Internal Server Error C:\Program Files\PHP\v5.4\php-cgi.exe - The FastCGI process exited unexpectedly Notification ExecuteRequestHandler Error Code 0xc0000005 Handler PHP54_via_FastCGI – MirrorMirror Dec 24 '12 at 12:23

0 Answers0