2017-10-06 17 views
0

私は1時間以上SOを検索していましたが、問題を解決できませんでした。なんらかの理由で、ページ上に262行目にParse Error:syntax error unexpectedとエラーがあります。これはelse条件のための閉じ括弧です。parse error Unexpected} if-elseブロック

else条件を削除したので、コードは円滑に実行されました。その後、私は戻って、他の条件の中のすべてを削除しましたが、それでもエラーは同じです、私は閉じ目が予期しない理由が混乱しています。ここで

はそう可能な答えのように行わコメントするコード

if(isset($_POST['sendEmailNotification'])){ 

$keyword = $_POST['sendEmailNotification']; 
$sql = "SELECT * FROM team where keyword = '$keyword'" ; 
$sql_result = mysqli_query($conn,$sql) or die (mysqli_error($conn)); 
while ($row = mysqli_fetch_assoc($sql_result)){ 
    $abcd = $row; 
} 

$htmlContent = file_get_contents ("email_template_header.php"); 
$registerURL = $siteURL.'/register/'; 

if ($abcd['claimed'] == 1) { 

    $htmlContent .= "<p>Hey,</p>"; 
    $htmlContent .= "<p>Hope you're doing well!!!</p>"; 
    $htmlContent .= "<p>Someone has submitted an image related to your business on www.trustedbusiness.reviews. He/She might be your customer or may be your employee/ex-employee.</p>"; 
    $htmlContent .= "<p>You can approve the image just by following these simple steps:</p>"; 
    $htmlContent .= "<ol>"; 
    $htmlContent .= "<li>View Business Center</li>"; 
    $htmlContent .= "<li>Click on Business Name</li>"; 
    $htmlContent .= "<li>Select 'Image' option from sidebar</li>"; 
    $htmlContent .= "<li>Approve the 'Image' & you're done</li>"; 
    $htmlContent .= "</ol>"; 
    $htmlContent .= "<p>If you need any help or have any suggestions to make the User Experience better. Please feel free to contact Trusted Business Reviews team.</p>"; 
    $htmlContent .= "<p>Thanks</p>"; 

} 
else { 

    $htmlContent .= "<p>Hey,</p>"; 
    $htmlContent .= "<p>Hope you're doing well!!!</p>"; 
    $htmlContent .= "<p>Someone has submitted an image related to your business on www.trustedbusiness.reviews. He/She might be your customer or maybe your employee/ex-employee.</p>"; 
    $htmlContent .= "<p>Uh-oh!</p>"; 
    $htmlContent .= "<p>You haven't claimed your business on Trusted Business Reviews? No problem!</p>"; 
    $htmlContent .= "<p>You can claim this by following these simple & super easy steps:</p>"; 
    $htmlContent .= "<ol>"; 
    $htmlContent .= "<li>Register here</li>"; 
    $htmlContent .= "<li>Open your Business Listing Page</li>"; 
    $htmlContent .= "<li>Click on 'Claim This Business'</li>"; 
    $htmlContent .= "<li>Enter your domain email address</li>"; 
    $htmlContent .= "<li>Enter Verification Code</li>"; 
    $htmlContent .= "<li>You're Done</li>"; 

    $htmlContent .= "</ol>"; 
    $htmlContent .= "<p>You can make the desired changes in the information (if needed) after 'claim this business' process.</p>"; 
    $htmlContent .= "<p>Later, You can approve the image just by following these simple steps:</p>"; 
    $htmlContent .= "<ol>"; 
    $htmlContent .= "<li>View Business Center</li>"; 
    $htmlContent .= "<li>Click on Business Name</li>"; 
    $htmlContent .= "<li>Select 'Image' option from sidebar</li>"; 
    $htmlContent .= "<li>Approve the 'Image' & you're done</li>"; 
    $htmlContent .= "</ol>"; 
    $htmlContent .= "<p>If you need any help or have any suggestions to make the User Experience better. Please feel free to contact Trusted Business Reviews team.</p>"; 
    $htmlContent .= "<p>Thanks</p>"; 
} 
$htmlContent .= file_get_contents ("email_template_footer.php"); 
$to = $abcd['b_email']; 

require 'PHPMailerAutoload.php'; 

$mail = new PHPMailer; 
$mail->isSMTP(); 
$mail->Host = 'localhost'; 
$mail->SMTPAuth = false; 
$mail->SMTPSecure = 'tls'; 
$mail->Port = 25; 
$mail->setFrom('[email protected]', 'ABC'); 
$mail->addAddress($to); 
$mail->isHTML(true); 
$mail->Subject = 'New Image Uploaded'; 
$mail->Body = $htmlContent; 
$mail->send(); 
$mail->clearAddresses(); 
} 
+0

投稿したコードは解析エラーを生成しないため、問題は別の場所にある必要があります。 – jeroen

+0

strange ...私は私の目の前でそれを見ています。 –

+0

ブラケットのような構文エラーについては、それは必ずしも同じではありません。それはこのコードのどこかで破られていなければなりません。 –

答えて

2

不足の点である:

私は(あなたのような)私のコードは大丈夫だったとき「エラーを解析する」謎の相次ぐを持っていました。

私の場合は、Webページのサンプルコードをコピーして貼り付ける際に、私のPC(OS /ブラウザ?)によって何らかの形で挿入された偽の隠し文字が原因でした。

else {

"else"と "{"の間のスペースが実際に "スペース"でない場合は、その後の{が無視される可能性があります。結果:else文の早期終了 つまりelse $htmlContent .= "<p>Hey,</p>";残りのconacatenationsはelseブロック外のステートメントとして処理され、閉じる "}"は無効として処理されます。

else節を削除して手動で再入力してみてください。

エディタでコードを開くと、非表示の文字が表示されます。 HTMLキット(私だと思います)表示 - >エディタ - >隠し文字は空白の実線ではなく黒で表示されます。

+0

あなたは正しく、閉じ目の近くにいくつかの目に見えない文字があります。私はそれらを削除し、それは魅力のように働いた。 –

関連する問題