猿问

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

第 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 行


婷婷同学_
浏览 205回答 2
2回答

呼如林

这个:if&nbsp;(!filter_var($email,FILTER_VALIDATE_EMAIL&nbsp;&&&nbsp;!preg_match("/^[a-zA-Z0-9]*$/",$username))&nbsp;{应该是这样的:if&nbsp;(!filter_var($email,FILTER_VALIDATE_EMAIL)&nbsp;&&&nbsp;!preg_match("/^[a-zA-Z0-9]*$/",$username))&nbsp;{

炎炎设计

它解决了请检查此代码(!filter_var($email,FILTER_VALIDATE_EMAIL && !preg_match("/^[a-zA-Z0-9]*$/",$username)) here add one bracket&nbsp;if (!filter_var($email,FILTER_VALIDATE_EMAIL && !preg_match("/^[a-zA-Z0-9]*$/",$username))) {&nbsp; &nbsp; header("Location: ../signup.php?error=invalidemailusername");&nbsp; //this is line 12 with the issue&nbsp; &nbsp; exit();&nbsp; }
随时随地看视频慕课网APP
我要回答