gpt4 book ai didi

php - 注册 script.php 不起作用

转载 作者:行者123 更新时间:2023-11-29 08:29:55 25 4
gpt4 key购买 nike

我的注册脚本不起作用。它曾经可以工作,但后来突然停止工作。我不知道我做了什么或发生了什么。我已经尝试了大约一个小时来找出问题所在,但我似乎找不到它。

会发生什么?当我单击注册时,我没有收到任何错误,但它没有上传到数据库:

当我输入: $res = mysql_query($query) or die ("ERROR"); 它显示 ERROR 所以我认为它与该代码有关:

//=============Configuring Server and Database=======
$host = 'localhost';
$user = 'root';
$password = '';
//=============Data Base Information=================
$database = 'login';

$conn = mysql_connect($host,$user,$password) or die('Server Information is not Correct'); //Establish Connection with Server
mysql_select_db($database,$conn) or die('Database Information is not correct');

//===============End Server Configuration============

//=============Starting Registration Script==========

$username = mysql_real_escape_string($_POST['username']);

$password = mysql_real_escape_string($_POST['pass1']);

$email = mysql_real_escape_string($_POST['email']);

$country = mysql_real_escape_string($_POST['country']);

$rights = '0';

$IP = $_SERVER['REMOTE_ADDR'];


//=============To Encrypt Password===================

//============New Variable of Password is Now with an Encrypted Value========
$query = mysql_query("SELECT username FROM users WHERE username = '".$username."'");
if (mysql_num_rows($query) > 0)
{
echo 'Username or email already in use.';
}
else{
if(isset($_POST['btnRegister'])) //===When I will Set the Button to 1 or Press Button to register
{
$query = "insert into users(username,password,email,country,rights,IP,registrated)values('$username','$password','$email','$country',$rights,$IP,NOW())" ;
$res = mysql_query($query);

header("location:load.php");
}
}

最佳答案

我认为您收到错误是因为您在查询中缺少两列的一些引号,这些列实际上看起来不是整数

'$email','$country',$rights,$IP,NOW())" //$rights and $ip doesn't have quotes 

所以你的查询看起来像这样

"insert into users(username,password,email,country,rights,IP,registrated)values('$username','$password','$email','$country','$rights','$IP',NOW())" 

关于php - 注册 script.php 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16941603/

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