我试图用XAMPP和sql Server做一个简单的连接。但是当我试图输入数据或连接到数据库时,我会遇到这个错误。错误是什么?我的项目急需它。我不知道为什么php第9行是错误。
致命错误:未捕获错误:调用C:\xampp\htdocs\last1\new\register.php:19中的未定义方法mysqli::error()
<?php
/* Registration process, inserts user info into the database
and sends account confirmation email message
*/
// Set session variables to be used on profile.php page
$_SESSION['email'] = $_POST['email'];
$_SESSION['first_name'] = $_POST['firstname'];
$_SESSION['last_name'] = $_POST['lastname'];
// Escape all $_POST variables to protect against SQL injections
$first_name = $mysqli->escape_string($_POST['firstname']);
$last_name = $mysqli->escape_string($_POST['lastname']);
$email = $mysqli->escape_string($_POST['email']);
$password = $mysqli->escape_string(password_hash($_POST['password'], PASSWORD_BCRYPT));
$hash = $mysqli->escape_string( md5( rand(0,1000) ) );
// Check if user with that email already exists
**$result = $mysqli->query("SELECT * FROM users WHERE email='$email'") or die($mysqli->error());**
// We know user email exists if the rows returned are more than 0
if ( $result->num_rows > 0 ) {
$_SESSION['message'] = 'User with this email already exists!';
header("location: error.php");
}
else { // Email doesn't already exist in a database, proceed...
// active is 0 by DEFAULT (no need to include it here)
$sql = "INSERT INTO users (first_name, last_name, email, password, hash) "
. "VALUES ('$first_name','$last_name','$email','$password', '$hash')";
// Add user to the database
if ( $mysqli->query($sql) ){
$_SESSION['active'] = 0; //0 until user activates their account with verify.php
$_SESSION['logged_in'] = true; // So we know the user has logged in
$_SESSION['message'] =
"Confirmation link has been sent to $email, please verify
your account by clicking on the link in the message!";
// Send registration confirmation link (verify.php)
$to = $email;
$subject = 'Account Verification ( clevertechie.com )';
$message_body = '
Hello '.$first_name.',
Thank you for signing up!
Please click this link to activate your account:
http://localhost/login-system/verify.php?email='.$email.'&hash='.$hash;
mail( $to, $subject, $message_body );
header("location: profile.php");
}
else {
$_SESSION['message'] = 'Registration failed!';
header("location: error.php");
}
}
请帮帮我:(谢谢你们;*
$mysqli->error()
应该是$mysqli->error
,因为error
是属性,而不是方法。
致命错误:未捕获错误:调用未定义的方法mysqli::execute()在C:\xampp\htdocs\search\index.php:58堆栈跟踪:#0{main}抛出在第58行的C:\xampp\htdocs\search\index.php 这是第58行 我试图创建一个简单的实时搜索。
我用这些类创建了一个登录名,但给了我一个错误 (!)致命错误:未捕获的错误:调用未定义的方法UserController::c在第17行的C:\xampp\htdocs\progetto个性\控制器\User Controller.php ( ! ) 错误:调用C:\xampp\htdocs\progetOpersonale\controllers\User Controller中未定义的方法Us
我的代码怎么了 帕西恩视图- 控制器- 注意:未定义的索引:psn在C:\xampp\htdocs\hamil\app\view\pasien\index.php行202 警告:在第202行的C:\xampp\htdocs\bunil\app\view\pasien\index.php中为Foreach()提供的参数无效 致命错误:未捕获错误:调用C:\xampp\htdocs\bumil\app
问题内容: 我试图与XAMPP和MySQL服务器建立简单连接,但是每当我尝试输入数据或连接到数据库时,都会出现此错误。 致命错误:未捕获错误:在C:\ xampp \ htdocs \ register.php:22中调用未定义函数mysql_connect() 堆栈跟踪:#0 {main}在第22行的C:\ xampp \ htdocs \ register.php中抛出 第22行的示例: 问题
我在尝试访问http://localhost/phpmyadmin/时收到以下错误: 在这里回顾了类似的主题后,我做了以下工作: null 我运行的是Windows10,Apache2.4-64bits、PHP7-64bits和mysqlserver5.7。Apache运行良好,PHP也运行良好(访问info.PHP无需担心) 谢了。
我正在按照一个在线教程来创建一个迷你购物车,一切都很顺利,但现在我得到了这个错误: 致命错误:未捕获错误:调用未定义函数mysql_query()