Php if-else块中出现意外的分析错误}
我已经搜索了一个多小时,但无法解决我的问题。由于某种原因,第262行中出现了一个错误,名为Parse error:syntax error unexpected}。它正在关闭else条件的括号 我删除了else条件,代码运行顺利。然后我返回并删除了其他条件中的所有内容,但错误仍然是一样的,我不明白为什么结束括号是意外的 这是密码Php if-else块中出现意外的分析错误},php,syntax-error,php-parse-error,Php,Syntax Error,Php Parse Error,我已经搜索了一个多小时,但无法解决我的问题。由于某种原因,第262行中出现了一个错误,名为Parse error:syntax error unexpected}。它正在关闭else条件的括号 我删除了else条件,代码运行顺利。然后我返回并删除了其他条件中的所有内容,但错误仍然是一样的,我不明白为什么结束括号是意外的 这是密码 if(isset($_POST['sendEmailNotification'])){ $keyword = $_POST['sendEmailNotificatio
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('abc@mail.com', 'ABC');
$mail->addAddress($to);
$mail->isHTML(true);
$mail->Subject = 'New Image Uploaded';
$mail->Body = $htmlContent;
$mail->send();
$mail->clearAddresses();
}
if(isset($\u POST['sendmailnotification'])){
$keyword=$_POST['sendmailnotification'];
$sql=“从团队中选择*,其中关键字='$keyword';
$sql_result=mysqli_query($conn,$sql)或die(mysqli_error($conn));
while($row=mysqli\u fetch\u assoc($sql\u result)){
$abcd=$row;
}
$htmlContent=file\u get\u contents(“email\u template\u header.php”);
$registerURL=$siteURL'/register/';
如果($abcd['claimed']==1){
$htmlContent.=“嘿,”;
$htmlContent.=“希望你做得很好!!!”;
$htmlContent.=“有人在www.trustedbusiness.reviews上提交了与您的业务相关的图像。他/她可能是您的客户,也可能是您的员工/前员工。”;
$htmlContent.=“您只需按照以下简单步骤批准图像:”;
$htmlContent.=“”;
$htmlContent.=“查看商务中心” ”;
$htmlContent.=“点击企业名称” ”;
$htmlContent.=“从侧边栏中选择“图像”选项” ”;
$htmlContent.=“批准‘图像’&您已经完成了” ”;
$htmlContent.=“”;
$htmlContent.=“如果您需要任何帮助或建议来改善用户体验,请随时联系Trusted Business Reviews团队。”;
$htmlContent.=“谢谢””;
}
否则{
$htmlContent.=“嘿,”;
$htmlContent.=“希望你做得很好!!!”;
$htmlContent.=“有人在www.trustedbusiness.reviews上提交了与您的业务相关的图片。他/她可能是您的客户,也可能是您的员工/前员工。”;
$htmlContent.=“Uh-oh!”;
$htmlContent.=“您还没有在受信任的业务评论上声明您的业务?没问题!”;
$htmlContent.=“您可以通过以下简单的步骤来声明这一点:”;
$htmlContent.=“”;
$htmlContent.=“在此处注册” ”;
$htmlContent.=“打开您的业务列表页面” ”;
$htmlContent.=“点击‘申请这笔生意’ ”;
$htmlContent.=“输入您的域电子邮件地址” ”;
$htmlContent.=“输入验证码” ”;
$htmlContent.=“您完成了” ”;
$htmlContent.=“”;
$htmlContent.=“您可以在“申请此业务”流程之后对信息进行所需的更改(如果需要)。”;
$htmlContent.=“稍后,您只需按照以下简单步骤批准图像:”;
$htmlContent.=“”;
$htmlContent.=“查看商务中心” ”;
$htmlContent.=“点击企业名称” ”;
$htmlContent.=“从侧边栏中选择“图像”选项” ”;
$htmlContent.=“批准‘图像’&您已经完成了” ”;
$htmlContent.=“”;
$htmlContent.=“如果您需要任何帮助或建议来改善用户体验,请随时联系Trusted Business Reviews团队。”;
$htmlContent.=“谢谢””;
}
$htmlContent.=文件获取内容(“email\u template\u footer.php”);
$to=$abcd['b_email'];
需要“PHPMailerAutoload.php”;
$mail=新的PHPMailer;
$mail->isSMTP();
$mail->Host='localhost';
$mail->SMTPAuth=false;
$mail->SMTPSecure='tls';
$mail->Port=25;
$mail->setFrom('abc@mail.com","ABC",;
$mail->addAddress($to);
$mail->isHTML(true);
$mail->Subject='newimage Uploaded';
$mail->Body=$htmlContent;
$mail->send();
$mail->clearAddresses();
}
没有足够的分数作为可能的答案进行评论:
当我的代码(像你的一样)还不错的时候,我有一大堆神秘的“解析错误”
在我的例子中,它是由我的PC(OS/浏览器?)在从网页复制和粘贴示例代码的过程中以某种方式插入的虚假隐藏字符引起的
e、 g.else{
如果“else”和“{”之间的“space”实际上不是“space”,那么它可能会导致忽略后续的{
。结果:else语句提前终止
i、 e.else$htmlContent.=“Hey,”;
您的剩余Conacations将被视为else块之外的语句,并且结束“}”无效
尝试删除else子句并手动重新键入
如果这不起作用,请在编辑器中打开代码,以显示隐藏字符。在HTML工具包(我认为)视图->编辑器->隐藏字符中,这些字符将显示为纯黑色,而不是纯白色的空格。没有足够的点数进行注释,因此可能的答案是: 当我的代码(像你的一样)还不错的时候,我有一大堆神秘的“解析错误” 在我的例子中,它是由我的PC(OS/浏览器?)在从网页复制和粘贴示例代码的过程中以某种方式插入的虚假隐藏字符引起的 e、 g.
else{
如果“else”和“{”之间的“space”实际上不是“space”,那么它可能会导致忽略后续的{
。结果:else语句提前终止
i、 e.else$htmlContent.=“Hey,”;
您的剩余Conacations将被视为else块之外的语句,并且结束“}”无效
尝试删除else子句并手动重新键入
如果这不起作用,请在编辑器中打开代码,以显示隐藏字符视图->编辑器->隐藏字符将显示纯黑色字符,而不是纯白色空格。您发布的代码不会生成解析错误,因此问题一定在其他地方。奇怪……我正看到它就在我面前。