php - 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 行
解决方案
这个:
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)) {
推荐阅读
- java - 如何使 Eclipse txt 文件中的字符可见?
- ios - 该整数是否等于文本字段中的数字
- angular - ngModel 但使用反应形式的验证方法
- php - PHP - unlink() 适用于直接路径,但不是必需的
- javascript - 与firebase中的当前用户对象交互需要我输入user.user,为什么我必须输入两次user?
- http - http状态200而不是304
- c# - 在 Cake 中使用语句
- jquery - jQuery 无法访问动态创建元素的父级 - 父级未定义
- sql - 用 SQL 操作矩阵的逻辑步骤
- python - 200GB Sqlite 数据库文件搜索和检索