我的php没有';t创建新文件以保存我的表单数据

我的php没有';t创建新文件以保存我的表单数据,php,html,Php,Html,我为一个教堂的会员表格写了一些代码。提交表单时,应该使用填写表单的人的名字创建一个新的.txt文件。当我运行代码时,它工作了,我没有收到错误消息,但是没有创建文件。我做错了什么 这是我为它编写的php 答复问题: $data字符串有:而不是;最后 这将导致您的php脚本在创建文件名之前失败 因此没有错误可能是因为fopen命令中缺少倒逗号,所以出现了什么错误。fopen($myfile,“w”) $Salutation = trim($_POST['salutation']);

我为一个教堂的会员表格写了一些代码。提交表单时,应该使用填写表单的人的名字创建一个新的.txt文件。当我运行代码时,它工作了,我没有收到错误消息,但是没有创建文件。我做错了什么

这是我为它编写的php


答复问题:

$data字符串有:而不是;最后

这将导致您的php脚本在创建文件名之前失败


因此没有错误

可能是因为fopen命令中缺少倒逗号,所以出现了什么错误。fopen($myfile,“w”)
    $Salutation = trim($_POST['salutation']);
    $FirstName = trim($_POST['firstname']);
    $OtherName = ($_POST['othernames']);
    $LastName = trim($_POST['lastname']);
    $Gender = trim($_POST['Gender']);
    $Nationality = trim($_POST['nationality']);
    $DOB = trim($_POST['DOB']);
    $POB = trim($_POST['POB']);
    $Marital_Status = trim($_POST['MarStat']);
    $Occupation = trim($_POST['occupation']);
    $Workplace = trim($_POST['POW']);
    $Residence = trim($_POST['POR']);
    $Children = trim($_POST['Kids']);
    $Postal = trim($_POST['postal']);
    $Telephone = trim($_POST['telephone']);
    $Email = trim($_POST['email']);
    $Diocese = trim($_POST['diocese']);
    $Branch = trim($_POST['branch']);
    $HowLongBornAgain = trim($_POST['lengthBornAgain']);
    $WhenJoinLCI = trim($_POST['WJLCI']);
    $Member_Type = trim($_POST['memtype']);
    $HowFind = trim($_POST['howFind']);
    $Who_Knows_Name = trim($_POST['whoknowname']);
    $Who_Know_Num = trim($_POST['whoknownum']);
    $Who_Know_Rel = trim($_POST['whoknowrel']);

    $data = "Name | $Salutaion $FirstName $OtherName $LastName\n
            Gender | $Gender\n
            Nationality | $Nationality\n
            Date of Birth | $DOB\n
            Place of Birth | $POB\n
            Marital Status | $Marital_Status\n
            Occupation | $Occupation\n
            Workplace | $Workplace\n
            Residence | $Residence\n
            Children | $Children\n
            Postal Address | $Postal\n
            Telephone | $Telephone\n
            E-mail | $Email\n
            Diocese | $Diocese\n
            Branch | $Branch\n
            Years Born Again | $HowLongBornAgain\n
            When $Salutation $LastName joined LCI | $WhenJoinLCI\n
            Member Type | $Member_Type\n
            Found Lighthouse through | $HowFind\n
            Person Who Knows Member | $Who_Knows_Name\n
            $Who_Knows_Name \'s number | $Who_Know_Num\n
            Relationship between the two members | $Who_Know_Rel\n":

    $myfile = $Salutaion." ".$FirstName." ".$OtherName." ".$LastName.".txt";

    $create_file = fopen($myfile, w) or die("Can't open file.");
    fwrite($create_file, $data) or die("Couldn\'t write values to file.");

    fclose($create_file);



}