php
  • html
  • forms
  • contact-form
  • 2017-09-28 67 views -2 likes 
    -2

    這是我從中得到語法錯誤的代碼。PHP - Post語法錯誤

    <?php 
        if ($_POST['prestiti']){ 
         echo "<option value=".$_POST['prestiti']." 
         selected='selected'>.$_POST['prestiti']</option>";}  
        else{ 
         echo "<option value='No' selected='selected'>No</option>";} 
    ?> 
    

    錯誤 - >;

    unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or 
    T_NUM_STRING in line 
    

    提前謝謝!

    +0

    <?PHP的 \t \t \t \t如果($ _POST [ 'prestiti']){ \t \t \t \t \t回聲 「<選項值=」。$ _ POST [ 'prestiti']。」選擇\t = '選擇'> $ _ POST [ 'prestiti']「;} \t \t \t \t \t否則{ \t \t \t \t \t echo「」;} \t \t?> –

    回答

    0

    固定代碼這些錯誤嘗試這樣;

    if (isset($_POST['prestiti']) && $_POST['prestiti'] != ""){ 
        echo "<option value=".$_POST['prestiti']." selected='selected'>" . $_POST['prestiti'] ."</option>"; 
    }else{ 
        echo "<option value='No' selected='selected'>No</option>"; 
    } 
    
    1

    你有連接錯誤。你的錯誤是在行:selected='selected'>.$_POST['prestiti']你忘了"

    我在下面

    <?php 
        if ($_POST['prestiti']){ 
         echo "<option value=".$_POST['prestiti']." selected='selected'>".$_POST['prestiti']."</option>";} 
        else{ 
         echo "<option value='No' selected='selected'>No</option>"; 
        } 
    ?> 
    
    相關問題