2017-10-06 9 views
0

한 시간 이상 SO 검색을하고 있지만 문제가 해결되지 않았습니다. 어떤 이유로 인해 262 행의 Parse Error : syntax error unexpected와 같은 페이지에 오류가 있습니다. else 조건에 대한 닫는 대괄호입니다.구문 분석 오류 예기치 않은 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

이상한 ... 나는 바로 내 앞에 그것을보고있다. –

+0

대괄호와 같은 구문 오류 때문에 항상 그 줄은 같지 않다. 어딘가에서이 코드를 깨뜨려야합니다. –

답변

2

부족 점이다.

내 경우에는 웹 페이지의 예제 코드를 복사하여 붙여 넣을 때 내 PC (OS/브라우저?)에 의해 삽입 된 가짜 숨겨진 문자가 원인이었습니다.

else {

"else"와 "{"사이의 "공백"이 실제로 "공백"이 아닌 경우 다음의 {이 무시 될 수 있습니다. 결과 : else 문을 조기 종료하면 즉 else $htmlContent .= "<p>Hey,</p>"; 남은 conacatenations는 else 블록 외부의 문장으로 처리되고 닫는 "}"은 유효하지 않은 것으로 처리됩니다.

else 절을 ​​삭제하고 수동으로 다시 입력하십시오.

숨겨진 문자 표시로 설정된 편집기에서 코드가 열리지 않는 경우 HTML 키트 (내 생각 엔) 보기 -> 편집기 숨겨진 문자 공간의 단색 흰색과 반대로 단색 검정과 같은 문자를 표시합니다.

+0

닫았 으면 대괄호 근처에 보이지 않는 문자가 나타납니다. 나는 그들을 제거하고 그것은 매력처럼 일했습니다. –