gpt4 book ai didi

php - PHP : sytax error unexpected 'require_once' on registration page

转载 作者:行者123 更新时间:2023-12-03 08:05:32 26 4
gpt4 key购买 nike

我正在尝试从HTML表单创建一个注册页面,该表单可以验证到PHP页面(下面提供的代码),但是,当我提交表单时,出现以下错误:

( ! ) Parse error: syntax error, unexpected 'require_once' (T_REQUIRE_ONCE) in path/user_create.php



这是将表单输入内容输入数据库的代码:
<?php
session_start();
require_once __DIR__.'config.php';


if(isset($_POST['submit'])){
$username=$_POST['username'];
$password=$_POST['password'];
$email=$_POST['email'];

$sql = "INSERT INTO users ( username, password, email) VALUES ( :username, :password, :email )";

$query = $dbh->prepare( $sql );
$query->execute( array( ':username'=>$username, ':password'=>$password, ':address'=>$address, ':email'=>$email ) );

$result = $query->execute( array( ':username'=>$username, ':password'=>$password, ':email'=>$email ) );

if ( $result ){
echo "<p>Your Registration is complete</p>";
} else {
echo "<p>There was a problem with registration, please try again.</p>";
}
}

?>

谁能告诉我如何停止此错误?不知道这是语法错误还是其他错误?

最佳答案

我能看到的唯一错误是缺少斜杠。根据手册:

... This directory name does not have a trailing slash unless it is the root directory.



因此,您需要:
require_once __DIR__.'/config.php';
^ here

关于php - PHP : sytax error unexpected 'require_once' on registration page,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29561600/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com