为了账号安全,请及时绑定邮箱和手机立即绑定

php 解析错误,带有意外的“;” 在第 12 行,但没有任何问题

php 解析错误,带有意外的“;” 在第 12 行,但没有任何问题

PHP
婷婷同学_ 2021-12-03 10:32:13
第 12 行存在问题(显示该行的注释)。显然,有一个意想不到的';' (分号)在那一行。虽然唯一的分号是关闭在移动到下一行之前总是需要的特定行。 <?php// creating a master if to see if the submit button was pressed.if (isset($_POST['signup-submit'])) {// connecting to the database validation file in the same file.  require 'dbh.inc.php';  $username = $POST['username'];  $email = $POST['email'];  $password = $POST['password'];  $repeatPassword = $POST['repeat_password'];  //error handlers time!!  if (!filter_var($email,FILTER_VALIDATE_EMAIL && !preg_match("/^[a-zA-Z0-9]*$/",$username)) {    header("Location: ../signup.php?error=invalidemailusername");  //this is line 12 with the issue    exit();  }  else if (!preg_match("/^[a-zA-Z0-9]*$/",$username)) {    header("Location: ../signup.php?error=invalidusername&email=".$email);    exit();  }解析错误:语法错误,意外的“;” 在(没有隐私文件位置)在第 12 行
查看完整描述

2 回答

?
呼如林

TA贡献1798条经验 获得超3个赞

这个:

if (!filter_var($email,FILTER_VALIDATE_EMAIL && !preg_match("/^[a-zA-Z0-9]*$/",$username)) {

应该是这样的:

if (!filter_var($email,FILTER_VALIDATE_EMAIL) && !preg_match("/^[a-zA-Z0-9]*$/",$username)) {



查看完整回答
反对 回复 2021-12-03
?
炎炎设计

TA贡献1808条经验 获得超4个赞

它解决了


请检查此代码


(!filter_var($email,FILTER_VALIDATE_EMAIL && !preg_match("/^[a-zA-Z0-9]*$/",$username)) here add one bracket


 if (!filter_var($email,FILTER_VALIDATE_EMAIL && !preg_match("/^[a-zA-Z0-9]*$/",$username))) {

    header("Location: ../signup.php?error=invalidemailusername");  //this is line 12 with the issue

    exit();

  }


查看完整回答
反对 回复 2021-12-03
  • 2 回答
  • 0 关注
  • 204 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号