我正在按照本教程创建我正在使用的注册数据库。我回过头来看视频,然后看着评论,试图找到解决我的问题的方法。mysql错误显示不正确
我遇到的问题是,我设置的错误不能正确显示我的数据库。我有一个用户名为'lowheartrate',但是当我把它放在用户名字段中并尝试用它登录时,它告诉我我的其他错误之一,
“我们找不到那个用户名。注册?”
很高兴有效,但我需要其他人的工作。特别是不能工作了的有以下错误:
The 'user_active' error.
The 'user_exists' error.
这是与我有问题附属代码:
我的login.php它显示了代码的错误:
是他们连接在一起,并告诉它做的users.php代码:
的general.php:
的的init.php:
在users.php更好看:
<?php
function user_exists($username) {
$username = sanitize ($username);
return (mysql_result(mysql_query("SELECT COUNT(`user_id`) FROM `users` WHERE `username` = '$username'"),0) == 1) ? true : false;
}
function user_active($username) {
$username = sanitize ($username);
return (mysql_result(mysql_query("SELECT COUNT(`user_id`) FROM `users` WHERE `username` = '$username' AND `active` = 1"), 0) == 1) ? true : false;
}
?>
在login.php中更好看:
<?php
include ('core/init.php');
if (empty($_POST) === false) {
$username = $_POST['username'];
$password = $_POST['password'];
if (empty($username) == true || empty($password) == true) {
$errors[] = 'You need to enter a username and password.';
} else if (user_exists($username) == false) {
$errors[] = 'We can\'t find that username. Have you registered?';
} else if (user_active($username) == false) {
$errors[] = 'You haven\'t activated your account.';
} else {
// here
}
print_r($errors);
}
?>
一个更好看的init.php:
<?php
session_start();
error_reporting(0);
require 'database/connect.php';
require 'functions/general.php';
require 'functions/users.php';
$errors = array();
?>
一个更好的看general.php:
<?php
function sanitize($data) {
return mysql_real_escape_string($data);
}
?>
一个更好的看connect.php:
<?php
$connect_error = 'Sorry we\'re experiencing connection issues.';
$con = mysqli_connect('localhost','root','');
mysqli_select_db($con,'lr') or die($connect_error);
?>
一看表(登录。PHP的小部件):
<div class="widget">
<h2>Returning Member?</h2>
<div class="inner">
<form action="login.php" method="post">
<ul id="login">
<li>
<input type="text" name="username" placeholder="Username" autofocus >
</li>
<li>
<input type="password" name="password" placeholder="Password" >
</li>
<li>
<input type="submit" value="Log in" >
</li>
<li>
<a href="register.php">Create an Account</a>
</li>
</ul>
</form>
</div>
</div>
不知道它的问题,但在此处,它被显示在index.php:
<?php
$pageTitle = 'gLounge - Welcome to gLounge!';
include('includes/php/header.php');
?>
<!-- Middle content section -->
<div class="middle">
<div class="container">
<div class="col-md-9 content">
<h2>Use gLounge42 as your new source to connect with fellow gamers. We have plenty for you to look at.</h2>
<p>
gLounge42 allows all types of gamers on all types of consoles/platforms connect with each other with
unlimited amount of reasons to do so. Here at gLounge42 you can chat with them and go as far as posting
in forums to get members for you Call of Duty clan. Possibilities are endless so go ahead and get your
account setup now with gLounge42!
</p>
<div class="to-tutorial">
<p><strong>Register an Account to get started:</strong></p>
<a href="register.php" class="btn btn-success">Register</a>
</div>
</div>
<!-- Includes the login widget on the top right side of page -->
<?php include('includes/widgets/login.php');?>
<!-- Includes the side navigation area -->
<?php include('includes/php/sideNavigation.php');?>
</div>
</div>
<?php
include('includes/php/footer.php')
?>
数据库的元素,我正在使用:
个
连接到数据库中的用户:
如果需要任何更多信息,请让我知道。
此致敬礼,
科迪
@ Arif_suhail_123我仍然得到同样的错误,当我用2代替3 '=' 代替的迹象。没有拿起user_active不幸 – cscodismith 2014-10-11 05:31:42
@ Arif_suhail_123是的,仍然没有找到我的解决方案。会爱你的输入请 – cscodismith 2014-10-11 06:21:38
@ Arif_suhail_123当我添加你给我的代码并继续到login.php它没有任何错误代码什么都不是什么好事,因为我继续登录login.php,甚至没有把一个用户名或密码,它并没有给我一个错误代码。 – cscodismith 2014-10-11 06:32:42