我的php代码中遇到了问题,说我:解析错误:语法错误,意外的"如果"(T_IF),我试图修复很多时间,但没有结果。无论如何,我的代码是:
<?php
include 'header.php';
include 'config.php';
include 'footer.php';
?>
<?php
if(isset($_POST['rgstdo'])){
$u_name = strip_tags($_POST['u_name']);
$u_pwd = md5($_POST['u_pwd']);
$u_email = strip_tags($_POST['u_email']);
if(!empty($u_name) or !empty($u_pwd) or !empty($u_email)){
$u_name = strip_tags($_POST['u_name']);
$u_pwd = md5($_POST['u_pwd']);
$u_email = strip_tags($_POST['u_email']);
}
if(empty($u_name) or empty($u_pwd) or empty($u_email)){
echo "<div class='alert alert-danger' role='alert'>ERROR, All fields were filled</div>";
}else{
$dbadduser = mysql_query("INSERT INTO admins
('u_name','u_pwd','u_email')
VALUES
('$u_name','$u_pwd','$u_email')") or die (mysql_error());
if(isset($dbadduser)){
echo "<div class='alert alert-success' role='alert'>Done, now you can login</div>";
include './/index.php'
exit;()
}
}
}
?>
错误消息: Parse error: syntax error, unexpected 'if' (T_IF) in C:xampphtdocskownloadpathadmin-rgst.php on line 29
<?php
include 'header.php';
include 'config.php';
include 'footer.php';
if(isset($_POST['rgstdo'])){
$u_name = strip_tags($_POST['u_name']);
$u_pwd = md5($_POST['u_pwd']);
$u_email = strip_tags($_POST['u_email']);
if(!empty($u_name) or !empty($u_pwd) or !empty($u_email)){
$u_name = strip_tags($_POST['u_name']);
$u_pwd = md5($_POST['u_pwd']);
$u_email = strip_tags($_POST['u_email']);
}
if(empty($u_name) or empty($u_pwd) or empty($u_email)){
echo "<div class='alert alert-danger' role='alert'>ERROR, All fields were filled</div>";
}
else {
$dbadduser = mysql_query("INSERT INTO admins ('u_name','u_pwd','u_email') VALUES ('$u_name','$u_pwd','$u_email')") or die (mysql_error());
if(isset($dbadduser)){
echo "<div class='alert alert-success' role='alert'>Done, now you can login</div>";
include './/index.php';
exit();
}
}
}
?>
刚刚删除了代码中的特殊字符。 并将exit;()
中的分号';'
更正为 exit();
我使用 mysqli所以我添加mysql_query()而不是mysqli_query()是我的错误
<?php
include 'header.php';
include 'footer.php';
if(isset($_POST['rgstdo'])){
$u_name = strip_tags($_POST['u_name']);
$u_pwd = md5($_POST['u_pwd']);
$u_email = strip_tags($_POST['u_email']);
if(!empty($u_name) or !empty($u_pwd) or !empty($u_email)){
$u_name = strip_tags($_POST['u_name']);
$u_pwd = md5($_POST['u_pwd']);
$u_email = strip_tags($_POST['u_email']);
}
if(empty($u_name) or empty($u_pwd) or empty($u_email)){
echo "<div class='alert alert-danger' role='alert'>ERROR, All fields were filled</div>";
}
else {
$dbadmins = **mysqli_query** ("INSERT INTO admins ('u_name','u_pwd','u_email') VALUES ('$u_name','$u_pwd','$u_email')") or die (**mysqli_error**());
if(isset($dbadmin)){
echo "<div class='alert alert-success' role='alert'>Done, now you can login</div>";
include './/index.php';
mysqli_close($con);
}
}
}
?>