0

それで、私のコードは昨日の私のウェブサイトにぴったりでした...ドキュメントに誰も(1の)が現れないことに気付くまで!!! コード全体を検索しましたが、何も問題がないようです!

それが PHP (5.3) のバグなのか、それとも何かなのかはわかりません。修正する必要があります。

要約: すべての 1 (1) は原因不明で消去されます)

私のコードはここにあります:

  echo "Please wait while we submit your recipe...";

  //getting form data
  $thedate = Date("d-m-Y_H:i:s");
  $title = $_POST['Title'];
  $description = $_POST['Descript'];
  $ingredients = $_POST['Ingredients'];
  $instructions =$_POST['Instructions'];
  $notes = $_POST['Notes'];
  $name = $_POST['Name'];

  //replacement for extra characters
  $title = str_replace("\'" && "\"", "" , $title);
  $description = str_replace("\'" && "\"", "" , $description);
  $ingredients = str_replace("\'" && "\"", "" , $ingredients);
  $instructions = str_replace("\'" && "\"", "" , $instructions);
  $notes = str_replace("\'" && "\"", "" , $notes);
  $name = str_replace("\'" && "\"", "" , $name);
  $title = str_replace("\\", "" , $title);
  $the_recipe_url="RecibaseWaitingList/".$thedate."--".$title.".txt";
  $the_recipe_url = str_replace("'", "" , $the_recipe_url);
  $the_recipe_url = str_replace("\"", "" , $the_recipe_url);
  $the_recipe_url = str_replace("?", "" , $the_recipe_url);
  $the_recipe_url = str_replace(chr(10), "_", $the_recipe_url);

  //bugs show up before or after this 
  echo '...';

    //Checking to see if all required fields are filled
    if($title !== '')
    {
        if($ingredients !=='')
        {
            if($instructions !=='')
            {
                          //writing to the file
                          $writetothefile = fopen($the_recipe_url, 'c');
                          fwrite($writetothefile, $name." submitted this recipe on ".$thedate." \r\n \r\n "); 
                          fwrite($writetothefile, "Title: ".$title." \r\n ");
                          fwrite($writetothefile, $description." \r\n ");
                          fwrite($writetothefile, " \r\n ");
                          fwrite($writetothefile, "Ingredents:\r\n".$ingredients." \r\n");
                          fwrite($writetothefile, " \r\n ");
                          fwrite($writetothefile, "Instructions: \r\n ".$instructions." \r\n ");
                          fwrite($writetothefile, "\r\n ");
                          fwrite($writetothefile, "Notes: \r\n" . $notes . "\r\n \r\n ");
                          fwrite($writetothefile, "Thank you ".$name." for submitting this recipe! \r\n \r\n When you're done with the recipe, just click the back button.");
                          fclose($writetothefile);

                          //echo's for the user to see      
                          echo '<br />Your recibase recipe url is <a href="' . $the_recipe_url . '">' . $the_recipe_url . '</a>.';
                          echo "<br />";
                          echo "<br />";                      
                          echo "Thank you for being so generous with your time and entering your recipe. We hope you enjoy using the rest of the site!< br />"; 
                          echo "<br />";                
                          echo '<a href="http://recibase.musicsuper.org/input.php">Click Here</a> to enter in another recipe.<br />';
                          echo "...and we're done!";
             }else{echo "Go back, and enter the <b><i>Instructions</i></b> of your recipe please!".'<br><br><a href="javascript:history.go(-1);">'.'<--- Go Back</a>';}
          }else{echo "Go back, and enter the <b><i>Ingredients</i></b> in your recipe please!".'<br><br><a href="javascript:history.go(-1);">'.'<--- Go Back</a>';}
      }else{echo "Go back, and enter the <b><i>Title</i></b> of your recipe please!".'<br><br><a href="javascript:history.go(-1);">'.'<--- Go Back</a>';

1が消える原因は何ですか?そして、なぜそれが起こっているのですか?

どんなアイデアでも大歓迎です。

このコードとサンプル レシピの実行結果を見たい場合は、こちらにアクセスしてください: http://recibase.musicsuper.org/AllOfYourRecipes/RecibaseWaitingList/15-02-2013_13:38:17--Deer%20Liver% 20Pate.txt

4

3 に答える 3

0

私はおそらくあなたの問題を見つけました:

この関数を次のように使用することはできません。

str_replace("\'" && "\"", "" , $ingredients);

("\'" && "\"")TRUEブール値および文字列として評価され"1"ます。

関数に配列を渡します。

str_replace(array("\'", "\""), "" , $ingredients);
于 2013-02-15T22:57:12.063 に答える