0

サーバー上でファイルをテストしようとしたときに、エラー (500 Internal Server Error) を受け取りました。すべてがmamp(ローカル)で正常に機能し、エラーは発生しませんでした。エラーのあるコードは次のとおりです。

<?php
    include_once('../classes/places.class.php');
try
{
    $oPlace = new Places();
    $oPlace->Street = $_POST['place'];
    $oPlace->HouseNumber = $_POST['number'];
    $oPlace->Name = $_POST['Name'];
    if($oPlace->placeAvailable())
    {
        $feedback['status'] = "success";
        $feedback['available'] = "yes";
        $feedback["message"] = "Go ahead, street is available";
    }   
    else
    {
        $feedback['status'] = "success";
        $feedback['available'] = "no";
        $feedback["message"] ="De zaak " . "'" . $_POST['name'] . "'". " is reeds op dit adres gevestigd." ;;
    }
}
catch(exception $e)
{
    $feedback['status'] = "error";
    $feedback["message"] =$e->getMessage();

}
header('Content-type: application/json');
echo json_encode($feedback);
?>
4

3 に答える 3

1

What version of PHP is it?

If prior to 5.2 you need to install the JSON PECL package.

If 5.20 or later you have to check that PHP was compiled without the --disable-json option.

于 2012-05-05T11:28:56.543 に答える
0
$feedback["message"] ="De zaak " . "'" . $_POST['name'] . "'". " is reeds op dit adres gevestigd." ;;

もっと似ている必要があります

$feedback["message"] ="De zaak " . "'" . $_POST['name'] . "'". " is reeds op dit adres gevestigd." ;

セミコロンを1つ追加しすぎると、エラーが発生することがあります

于 2012-05-05T11:24:01.347 に答える
-1
<?php
include_once('../classes/places.class.php');
/* This if for debugging */
foreach ($_GET as $k => $v) $_POST[$k] = $v;
// Access in your browser: pathToFilePHPCalled.php?place=SomePlace&number=14&Name=MyName
$feedback['data'] = $_POST;
/* This if for debugging */

$feedback = array();
try
{
    $oPlace = new Places();
    $oPlace->Street = $_POST['place'];
    $oPlace->HouseNumber = $_POST['number'];
    $oPlace->Name = $_POST['Name']; // Make sure this is $_POST['Name'] and not $_POST['name'] this might be your error
    if($oPlace->placeAvailable())
    {
        $feedback['status'] = "success";
        $feedback['available'] = "yes";
        $feedback["message"] = "Go ahead, street is available";
    }   
    else
    {
        $feedback['status'] = "success";
        $feedback['available'] = "no";
        $feedback["message"] ="De zaak " . "'" . $_POST['name'] . "'". " is reeds op dit adres gevestigd." ;
    }
}
catch(Exception $e)
{
    $feedback['status'] = "error";
    $feedback["message"] =$e->getMessage();

}
header('Content-type: application/json');
echo json_encode($feedback);
?>
于 2012-05-05T11:29:39.570 に答える