2017-09-14 8 views
-1
私はフォーム "のAddRow" と "deleteRowを" 使用

:この行にforeachの送信メール本文

PHP Parse error: syntax error, unexpected '.' in /home/metroloj/public_html/form/dene1/send.php on line 52

function addRow(tableID) { 
    var table = document.getElementById(tableID); 
    var rowCount = table.rows.length; 
    if(rowCount < 5){       // limit the user from creating fields more than your limits 
     var row = table.insertRow(rowCount); 
     var colCount = table.rows[0].cells.length; 
     for(var i=0; i<colCount; i++) { 
      var newcell = row.insertCell(i); 
      newcell.innerHTML = table.rows[0].cells[i].innerHTML; 
     } 
    }else{ 
     alert("Maximum Passenger per ticket is 5."); 

    } 
} 

しかしsend.phpカントは、電子メールを送信するには、私は、このエラーを与える

<?php foreach($BX_NAME as $a => $b){ ?> 

私はこのコード部分を送ってください:

<?php foreach($BX_NAME as $a => $b){ ?> 

<input type="text" readonly="readonly" name="BX_NAME[$a]" value="<?php echo $BX_NAME[$a]; ?>"> 

$mail->Body .= '<input type="text" readonly="readonly" name="BX_NAME[$a]" value="'. strip_tags($_POST['BX_NAME[$a]']) .'">'; 
+0

あなたは[phpmailerの](https://github.com/PHPMailer/を使用していますPHPMailer)? – showdev

答えて

0

ここに他の問題があるかもしれませんが、私は一般的なPHP構文を扱います。
混在したコンテンツ(HTMLとPHPを一緒に使用する場合)には、開閉用のPHPタグを使用する必要があります。

Everything outside of a pair of opening and closing tags is ignored by the PHP parser which allows PHP files to have mixed content. This allows PHP to be embedded in HTML documents, for example to create templates.

This works as expected, because when the PHP interpreter hits the ?> closing tags, it simply starts outputting whatever it finds... until it hits another opening tag...

Escaping from HTMLを参照してください。

さらに、foreachの例では、$BX_NAME[$a]$bと同じ値です。

foreach (array_expression as $key => $value)

のでarray_expression[$key]$valueと同じです。

例えば

<?php 
foreach ($BX_NAME as $a => $b) { 
    ?><tr> 
     <td><?=$a+1?></td> 
     <td> 
      <label>Name</label> 
      <input type="text" readonly="readonly" name="<?=$b?>" value="<?=$b?>"> 
     </td> 
    </tr><?php 
} 

文字列を構築し、連結する.を使用します。

foreach ($BX_NAME as $a => $b){ 

    ?><input type="text" readonly="readonly" name="<?=$b?>" value="<?=$b?>"><?php 
    $mail->Body .= '<input type="text" readonly="readonly" name="'.$b.'" value="'.strip_tags($_POST[$b]).'">'; 

} 
+0

ありがとう –

関連する問題