[HELP] Unknown column 'user_id' in 'field list' When register! [HELP]

Vezel

Member
Nov 20, 2012
92
4
Hi guys! When I register I get this error for some reason: Does anyone know any fix?
 

Jerry

not rly active lol
Jul 8, 2013
1,956
522
It's not the users table, it's something with the user_info table; here is the SQL you need to input;
--
-- Rakenne taululle `user_info`
--

CREATE TABLE IF NOT EXISTS `user_info` (
`user_id` int(11) NOT NULL,
`bans` int(11) NOT NULL DEFAULT '0',
`cautions` int(11) NOT NULL DEFAULT '0',
`reg_timestamp` double NOT NULL DEFAULT '0',
`login_timestamp` double NOT NULL DEFAULT '0',
`cfhs` int(11) NOT NULL DEFAULT '0',
`cfhs_abusive` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`user_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
 

Vezel

Member
Nov 20, 2012
92
4
It's not the users table, it's something with the user_info table; here is the SQL you need to input;
--
-- Rakenne taululle `user_info`
--

CREATE TABLE IF NOT EXISTS `user_info` (
`user_id` int(11) NOT NULL,
`bans` int(11) NOT NULL DEFAULT '0',
`cautions` int(11) NOT NULL DEFAULT '0',
`reg_timestamp` double NOT NULL DEFAULT '0',
`login_timestamp` double NOT NULL DEFAULT '0',
`cfhs` int(11) NOT NULL DEFAULT '0',
`cfhs_abusive` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`user_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
Tried that now, didn't work..

Post a screenshot of your user table here and the register page code.
Register Page:
HTML:
<?php
if(isset($_POST['register'])){
    $alertType = "danger"; // danger - warning - success - info
    $alert = "Registration under construction.";
}
?>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>HabZen Hotel</title>
        <meta name="description" content="HabZen, habbo, hotel, virtual, game" />
        <link rel="stylesheet" href="/web-gallery/css/index.css" type="text/css" />
        <link rel="stylesheet" href="/web-gallery/css/bootstrap.css" type="text/css" />
        <link rel="shortcut icon" href="app/tpl/skins/{skin}/static/images/favicon.gif"/>
        <script type="text/javascript" src="./web-gallery/js/jquery.min.js"></script>
        <script type="text/javascript" src="./web-gallery/js/bootstrap.js"></script>
    </head>
    <body>
        <div id="wrap-slash">
            <div id="wrap-center">
                <a href="index.php" id="logo"></a>
                <div id="users-online">{online} Users Playing!</div>
            </div>
        </div>
       
        <div id="wrap-body">
            <div id="wrap-center">
                <?php if(isset($alert)){ ?>
                <div class="alert alert-<?php echo $alertType; ?>">
                    <?php echo $template->form->error; ?>
                </div>
                <?php } ?>
                <div style="height:360px;">
                    <div id="register-left"></div>
                    <div id="register-right">
                        <div id="title">Register</div>
                        Enter the fields below to start playing.
                        <form id="register" method="post"><br />
                            <input type="text" name="reg_username" id="username" placeholder="Username" autofocus /><br />
                            <input type="text" name="reg_email" id="mail" placeholder="E-mail Adress" autofocus /><br />
                            <input type="password" name="reg_password" id="password" placeholder="Password" /><br />
                            <input type="password" name="reg_rep_password" id="password2" placeholder="Repeat Password" /><br />
                            <input type="submit" name="register" id="submit" value="" />
                        </form>
                    </div>
                    <div id="register-right2"></div>
                </div>
               
                <div id="logo_big"></div>
            </div>
        </div>
       
        <div id="wrap-footer">
            <div id="wrap-center">
                Copyright &copy;  HabZen 2014. All rights reserved to their respective owner(s).<br />
                HabZen is no way affiliated with Sulake Corporation Oy.
            </div>
        </div>
    </body>
</html>
users table:
 

Vezel

Member
Nov 20, 2012
92
4
It's not the users table, it's something with the user_info table; here is the SQL you need to input;
--
-- Rakenne taululle `user_info`
--

CREATE TABLE IF NOT EXISTS `user_info` (
`user_id` int(11) NOT NULL,
`bans` int(11) NOT NULL DEFAULT '0',
`cautions` int(11) NOT NULL DEFAULT '0',
`reg_timestamp` double NOT NULL DEFAULT '0',
`login_timestamp` double NOT NULL DEFAULT '0',
`cfhs` int(11) NOT NULL DEFAULT '0',
`cfhs_abusive` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`user_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
Shouldnt it be something in a table called "field list"?
 

Kyle

Member
Jul 4, 2010
61
8
PHP:
final public function addUser($username, $password, $email, $motto, $credits, $pixels, $rank, $figure, $gender, $seckey)    
    {        
        global $engine;                                
        $sessionKey = 'RevCMS-'.rand(9,999).'/'.substr(sha1(time()).'/'.rand(9,9999999).'/'.rand(9,9999999).'/'.rand(9,9999999),0,33);
        $engine->query("INSERT INTO users (username, password, mail, motto, credits, activity_points, rank, look, gender, seckey, ip_last, ip_reg, account_created, last_online, auth_ticket) VALUES('" . $username . "', '" . $password . "', '" . $email . "', '" . $motto . "', '" . $credits . "', '" . $pixels . "', '" . $rank . "', '" . $figure . "', '" . $gender . "', '" . $seckey . "', '" . $_SERVER['REMOTE_ADDR'] . "', '" . $_SERVER['REMOTE_ADDR'] . "', '" . time() . "', '" . time() . "', '" . $sessionKey . "')");    
       
        $getUser = mysql_query("SELECT * FROM users WHERE username = '".$username."'");
        while ($newUser = mysql_fetch_array($getUser))
        {
            $engine->query("INSERT INTO `bots` (`user_id`, `look`) VALUES ('".$newUser['id']."', '".$newUser['look']."')");
        }
       
        unset($sessionKey);   
   }

Your problem is bots table.
 

Vezel

Member
Nov 20, 2012
92
4
PHP:
final public function addUser($username, $password, $email, $motto, $credits, $pixels, $rank, $figure, $gender, $seckey)   
    {       
        global $engine;                               
        $sessionKey = 'RevCMS-'.rand(9,999).'/'.substr(sha1(time()).'/'.rand(9,9999999).'/'.rand(9,9999999).'/'.rand(9,9999999),0,33);
        $engine->query("INSERT INTO users (username, password, mail, motto, credits, activity_points, rank, look, gender, seckey, ip_last, ip_reg, account_created, last_online, auth_ticket) VALUES('" . $username . "', '" . $password . "', '" . $email . "', '" . $motto . "', '" . $credits . "', '" . $pixels . "', '" . $rank . "', '" . $figure . "', '" . $gender . "', '" . $seckey . "', '" . $_SERVER['REMOTE_ADDR'] . "', '" . $_SERVER['REMOTE_ADDR'] . "', '" . time() . "', '" . time() . "', '" . $sessionKey . "')");   
      
        $getUser = mysql_query("SELECT * FROM users WHERE username = '".$username."'");
        while ($newUser = mysql_fetch_array($getUser))
        {
            $engine->query("INSERT INTO `bots` (`user_id`, `look`) VALUES ('".$newUser['id']."', '".$newUser['look']."')");
        }
      
        unset($sessionKey);  
   }

Your problem is bots table.
So how do I fix it?
 

Vezel

Member
Nov 20, 2012
92
4
Sort the bots table out, it's missing user_id column or even remove the bots insert query from that function.
Yea, that worked but now I got the error: "Field 'name' doesn't have a default value"
Edit: NVM I deleted:
PHP:
        while ($newUser = mysql_fetch_array($getUser))
        {
            $engine->query("INSERT INTO `bots` (`user_id`, `look`) VALUES ('".$newUser['id']."', '".$newUser['look']."')");
        }
And now it works like a charm! tyvm! :) BTW, will this disable any function becouse I deleted it?
 

Kyle

Member
Jul 4, 2010
61
8
Yea, that worked but now I got the error: "Field 'name' doesn't have a default value"
Edit: NVM I deleted:
PHP:
        while ($newUser = mysql_fetch_array($getUser))
        {
            $engine->query("INSERT INTO `bots` (`user_id`, `look`) VALUES ('".$newUser['id']."', '".$newUser['look']."')");
        }
And now it works like a charm! tyvm! :) BTW, will this disable any function becouse I deleted it?
What EMU asre you using also, remove this aswel.
PHP:
$getUser = mysql_query("SELECT * FROM users WHERE username = '".$username."'");
Its not needed
 

Users who are viewing this thread

Top