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