活跃的MySQL添加 - 困惑


Active MySQL add - Confused

这是我

在点击"注册"电子邮件发送和所有内容后不断出现的错误,但是当我在激活下激活它时.php它给了我这个错误..:

Unknown column 'active' in 'field list'

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

下面是激活.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"添加到数据库的代码是什么,以便它与其他所有内容一起使用,请告诉我。也。。这是我当前的表.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 文档

或者,如果要重新创建表:

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;

另外,虽然这与您的问题没有直接关系,但请查看如何防止 PHP 中的 SQL 注入?以获取有关如何在代码中编写更安全的数据库查询的信息。