gpt4 book ai didi

php - Active MySQL 添加 - 困惑

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

这是我在点击“注册”后不断收到的错误,电子邮件已发送,但是当我在 activate.php 下激活它时,它给了我这个错误..:

Unknown column 'active' in 'field list'

我知道它希望我将该字段添加到我相信的数据库中。但是我不知道如何将它添加到数据库中的代码,比如名称和所有内容。所以它可以完全工作并且可以工作用这个脚本..

Activate.php 脚本代码如下:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>GamesFX > Sign up</title>
<link href="css/style.css" type="text/css" rel="stylesheet" />
</head>
<body>
<!-- start header div -->
<div id="header">
<h2>GamesFX > Sign up</h2>
</div>
<!-- end header div -->

<!-- start wrap div -->
<div id="wrap">
<!-- start PHP code -->
<?php

mysql_connect("info here", "my stuff",

"this is fine") or die(mysql_error()); // Connect to database server(localhost) with

username and password.
mysql_select_db("mysql works fine connecting") or die(mysql_error()); // Select

registration database.

if(isset($_GET['email']) && !empty($_GET['email']) AND isset

($_GET['hash']) && !empty($_GET['hash'])){
// Verify data
$email = mysql_escape_string($_GET['email']); // Set email

variable
$hash = mysql_escape_string($_GET['hash']); // Set hash

variable

$search = mysql_query("SELECT email, Activation

FROM gamesfx_members WHERE email='".$email."' AND Activation='".$hash."' AND active='0'") or die

(mysql_error());
$match = mysql_num_rows($search);

if($match > 0){
// We have a match, activate the account
mysql_query("UPDATE gamesfx_members SET active='1'

WHERE email='".$email."' AND Activation='".$hash."' AND active='0'") or die(mysql_error

());
echo '<div class="statusmsg">Your account has been

activated, you can now login</div>';
}else{
// No match -> invalid url or account has already

been activated.
echo '<div class="statusmsg">The url is either

invalid or you already have activated your account.</div>';
}

}else{
// Invalid approach
echo '<div class="statusmsg">Invalid approach, please use

the link that has been send to your email.</div>';
}

?>
<!-- stop PHP Code -->


</div>
<!-- end wrap div -->
</body>
</html>

如果有人能告诉我将值“active”添加到数据库以便它可以与其他所有内容一起使用的代码是什么,请告诉我。另外..这是我当前的 table.sql 文件:

    --
-- Table structure for table `gamesfx_members`
--

CREATE TABLE IF NOT EXISTS `gamesfx_members` (
`id` int(11) NOT NULL auto_increment,
`usr` varchar(32) collate utf8_unicode_ci NOT NULL default '',
`pass` varchar(32) collate utf8_unicode_ci NOT NULL default '',
`email` varchar(255) collate utf8_unicode_ci NOT NULL default '',
`Activation` varchar(40) DEFAULT NULL,
`regIP` varchar(15) collate utf8_unicode_ci NOT NULL default '',
`dt` datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (`id`),
UNIQUE KEY `usr` (`usr`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

最佳答案

ALTER TABLE `gamesfx_members` ADD `active` integer;

MySql docs

或者,如果您想重新创建表:

CREATE TABLE IF NOT EXISTS `gamesfx_members` (
`id` int(11) NOT NULL auto_increment,
`usr` varchar(32) collate utf8_unicode_ci NOT NULL default '',
`pass` varchar(32) collate utf8_unicode_ci NOT NULL default '',
`email` varchar(255) collate utf8_unicode_ci NOT NULL default '',
`Activation` varchar(40) DEFAULT NULL,
`regIP` varchar(15) collate utf8_unicode_ci NOT NULL default '',
`dt` datetime NOT NULL default '0000-00-00 00:00:00',
`active` integer NOT NULL default 0
PRIMARY KEY (`id`),
UNIQUE KEY `usr` (`usr`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

此外,虽然这与您的问题没有直接关系,但请查看 How can I prevent SQL injection in PHP?有关如何在代码中编写更安全的数据库查询的信息。

关于php - Active MySQL 添加 - 困惑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19796312/

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