PHP DOMDocument错误保存到磁盘上

|
function send_newsletter() {

    $name = $_POST[\'name\'];
    $last_name = $_POST[\'last_name\'];
    $email = $_POST[\'email\'];
    $city = $_POST[\'city\'];
    $address = \'n/a\';

    $doc = new DOMDocument(); 
    $doc->load(\'xml/lead.xml\');
    $doc->formatOutput = true; 

    $tags = $doc->getElementsByTagName(\'lead\');
    $r = $tags->item(0);

    $b = $doc->createElement( \'contact\' ); 
    $b->setAttribute(\'FirstName\', \'\'.$name.\'\');
    $b->setAttribute(\'LastName\', \'\'.$last_name.\'\');
    $b->setAttribute(\'Email\', \'\'.$email.\'\');
    $b->setAttribute(\'StreetAddress\', \'\'.$address.\'\');
    $b->setAttribute(\'City\', \'\'.$city.\'\');

    $r->appendChild( $b ); 

    if($doc->save(\"xml/lead.xml\")) {
        $the_return = array(\'request\'=>\'success\');
        echo json_encode($the_return);
    }

    else{
        $prompt = \"Sign up failed. Please try again.\";

        $the_return = array(\'request\'=>\'failed\',\'prompt\'=>$prompt);
        echo json_encode($the_return);
    }

    die();
}
该代码可在我的几个服务器上运行,但是我正在使用提供给我的测试服务器,由于某种原因它会引发500个内部服务器错误,因此我不知道代码出了什么问题。我在服务器上无法工作的代码上也遇到了类似的问题,原因通常是语法。 通过反复试验,我确定ѭ1是问题所在。我不知道为什么。 有人可以帮我看看吗?这可能是愚蠢的,如缺少报价。 谢谢     
已邀请:

要回复问题请先登录注册