TMan Posted February 20, 2009 Posted February 20, 2009 i have added a new currency, stats .... when adding a new account i get this query error QUERY ERROR: Column count doesn't match value count at row 1 Query was INSERT INTO userstats VALUES(367, 10, 10, 10, 10, 0) i was told i needed to add my values... to register.php register.php $r=$db->fetch_row($q); } $db->query("INSERT INTO users (username, login_name, userpass, level, clevel, rlevel, money, platinum, crystals, donatordays, user_level, energy, maxenergy, cenergy, maxcenergy, gas, maxgas, will, maxwill, brave, maxbrave, hp, maxhp, location, gender, signedup, email, bankmoney, lastip, lastip_signup) VALUES( '{$username}', '{$username}', md5('{$_POST['password']}'), 1, 1, 1, $sm, 0, 0, 0, 1, 12, 12, 12, 12, 4, 4, 100, 100, 5, 5, 100, 100, 1, '{$_POST['gender']}', unix_timestamp(), '{$_POST['email']}', -1, '$IP', '$IP')"); $i=$db->insert_id(); $db->query("INSERT INTO userstats VALUES($i, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 )"); $db->query("INSERT INTO mail VALUES ('',0,1,$i,unix_timestamp(),'Welcome','Welcome to Corrupted City, we hope you enjoy your stay here. If you need any assistance feel free to mail a staff member. Make sure you read the Game Rules and Help Tutorial')",$c); if($_POST['ref']) { require "global_func.php"; any help would be appreciated Quote
03laceys Posted February 20, 2009 Posted February 20, 2009 Re: [V2] Error when registering new accounts i have added a new currency, stats .... when adding a new account i get this query error QUERY ERROR: Column count doesn't match value count at row 1 Query was INSERT INTO userstats VALUES(367, 10, 10, 10, 10, 0) i was told i needed to add my values... to register.php register.php $r=$db->fetch_row($q); } $db->query("INSERT INTO users (username, login_name, userpass, level, clevel, rlevel, money, platinum, crystals, donatordays, user_level, energy, maxenergy, cenergy, maxcenergy, gas, maxgas, will, maxwill, brave, maxbrave, hp, maxhp, location, gender, signedup, email, bankmoney, lastip, lastip_signup) VALUES( '{$username}', '{$username}', md5('{$_POST['password']}'), 1, 1, 1, $sm, 0, 0, 0, 1, 12, 12, 12, 12, 4, 4, 100, 100, 5, 5, 100, 100, 1, '{$_POST['gender']}', unix_timestamp(), '{$_POST['email']}', -1, '$IP', '$IP')"); $i=$db->insert_id(); $db->query("INSERT INTO userstats VALUES($i, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 )"); $db->query("INSERT INTO mail VALUES ('',0,1,$i,unix_timestamp(),'Welcome','Welcome to Corrupted City, we hope you enjoy your stay here. If you need any assistance feel free to mail a staff member. Make sure you read the Game Rules and Help Tutorial')",$c); if($_POST['ref']) { require "global_func.php"; any help would be appreciated There try that. $r=$db->fetch_row($q); } $db->query("INSERT INTO users (username, login_name, userpass, level, clevel, rlevel, money, platinum, crystals, donatordays, user_level, energy, maxenergy, cenergy, maxcenergy, gas, maxgas, will, maxwill, brave, maxbrave, hp, maxhp, location, gender, signedup, email, bankmoney, lastip, lastip_signup) VALUES( '{$username}', '{$username}', md5('{$_POST['password']}'), 1, 1, 1, $sm, 0, 0, 0, 1, 12, 12, 12, 12, 4, 4, 100, 100, 5, 5, 100, 100, 1, '{$_POST['gender']}', unix_timestamp(), '{$_POST['email']}', -1, '$IP', '$IP')"); $i=$db->insert_id(); $db->query("INSERT INTO userstats VALUES($i, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 )"); $db->query("INSERT INTO mail VALUES ('',0,1,$i,unix_timestamp(),'Welcome','Welcome to Corrupted City, we hope you enjoy your stay here. If you need any assistance feel free to mail a staff member. Make sure you read the Game Rules and Help Tutorial')",$c); if($_POST['ref']) { require "global_func.php"; Quote
TMan Posted February 20, 2009 Author Posted February 20, 2009 Re: [V2] Error when registering new accounts <?php include "config.php"; global $_CONFIG; define("MONO_ON", 1); require "class/class_db_{$_CONFIG['driver']}.php"; $db=new database; $db->configure($_CONFIG['hostname'], $_CONFIG['username'], $_CONFIG['password'], $_CONFIG['database'], $_CONFIG['persistent']); $db->connect(); $c=$db->connection_id; $set=array(); $settq=$db->query("SELECT * FROM settings"); while($r=$db->fetch_row($settq)) { $set[$r['conf_name']]=$r['conf_value']; } //thx to [url]http://www.phpit.net/code/valid-email/[/url] for valid_email function valid_email($email) { // First, we check that there's one @ symbol, and that the lengths are right if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) { // Email invalid because wrong number of characters in one section, or wrong number of @ symbols. return false; } // Split it into sections to make life easier $email_array = explode("@", $email); $local_array = explode(".", $email_array[0]); for ($i = 0; $i < sizeof($local_array); $i++) { if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) { return false; } } if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { // Check if domain is IP. If not, it should be valid domain name $domain_array = explode(".", $email_array[1]); if (sizeof($domain_array) < 2) { return false; // Not enough parts to domain } for ($i = 0; $i < sizeof($domain_array); $i++) { if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) { return false; } } } return true; } session_start(); print <<<EOF <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr"> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> <meta name="description" content="ENTER DESCRIPTION"/> <meta name="keywords" content="ENTER KEYWORDS" /> <meta name="author" content="Cherry-Nectar.com" /> <link rel="stylesheet" type="text/css" href="style.css" media="screen" /> <title>{$set['game_name']}</title> <script type="text/javascript"> var xmlHttp // xmlHttp variable function GetXmlHttpObject(){ // This function we will use to call our xmlhttpobject. var objXMLHttp=null // Sets objXMLHttp to null as default. if (window.XMLHttpRequest){ // If we are using Netscape or any other browser than IE lets use xmlhttp. objXMLHttp=new XMLHttpRequest() // Creates a xmlhttp request. }else if (window.ActiveXObject){ // ElseIf we are using IE lets use Active X. objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP") // Creates a new Active X Object. } // End ElseIf. return objXMLHttp // Returns the xhttp object. } // Close Function function CheckPasswords(password){ // This is our fucntion that will check to see how strong the users password is. xmlHttp=GetXmlHttpObject() // Creates a new Xmlhttp object. if (xmlHttp==null){ // If it cannot create a new Xmlhttp object. alert ("Browser does not support HTTP Request") // Alert Them! return // Returns. } // End If. var url="check.php?password="+escape(password) // Url that we will use to check the password. xmlHttp.open("GET",url,true) // Opens the URL using GET xmlHttp.onreadystatechange = function () { // This is the most important piece of the puzzle, if onreadystatechange = equal to 4 than that means the request is done. if (xmlHttp.readyState == 4) { // If the onreadystatechange is equal to 4 lets show the response text. document.getElementById("passwordresult").innerHTML = xmlHttp.responseText; // Updates the div with the response text from check.php } // End If. }; // Close Function xmlHttp.send(null); // Sends NULL insted of sending data. } // Close Function. function CheckUsername(password){ // This is our fucntion that will check to see how strong the users password is. xmlHttp=GetXmlHttpObject() // Creates a new Xmlhttp object. if (xmlHttp==null){ // If it cannot create a new Xmlhttp object. alert ("Browser does not support HTTP Request") // Alert Them! return // Returns. } // End If. var url="checkun.php?password="+escape(password) // Url that we will use to check the password. xmlHttp.open("GET",url,true) // Opens the URL using GET xmlHttp.onreadystatechange = function () { // This is the most important piece of the puzzle, if onreadystatechange = equal to 4 than that means the request is done. if (xmlHttp.readyState == 4) { // If the onreadystatechange is equal to 4 lets show the response text. document.getElementById("usernameresult").innerHTML = xmlHttp.responseText; // Updates the div with the response text from check.php } // End If. }; // Close Function xmlHttp.send(null); // Sends NULL insted of sending data. } // Close Function. function CheckEmail(password){ // This is our fucntion that will check to see how strong the users password is. xmlHttp=GetXmlHttpObject() // Creates a new Xmlhttp object. if (xmlHttp==null){ // If it cannot create a new Xmlhttp object. alert ("Browser does not support HTTP Request") // Alert Them! return // Returns. } // End If. var url="checkem.php?password="+escape(password) // Url that we will use to check the password. xmlHttp.open("GET",url,true) // Opens the URL using GET xmlHttp.onreadystatechange = function () { // This is the most important piece of the puzzle, if onreadystatechange = equal to 4 than that means the request is done. if (xmlHttp.readyState == 4) { // If the onreadystatechange is equal to 4 lets show the response text. document.getElementById("emailresult").innerHTML = xmlHttp.responseText; // Updates the div with the response text from check.php } // End If. }; // Close Function xmlHttp.send(null); // Sends NULL insted of sending data. } // Close Function. function PasswordMatch() { pwt1=document.getElementById('pw1').value; pwt2=document.getElementById('pw2').value; if(pwt1 == pwt2) { document.getElementById('cpasswordresult').innerHTML="<font color='green'>OK</font>"; } else { document.getElementById('cpasswordresult').innerHTML="<font color='red'>Not Matching</font>"; } } </script> <style type="text/css"> <!-- body { color #F0F0F0; font:normal 10px Verdana; } a:visited,a:active,a:link { color: #546270; text-decoration: none; } a:hover { color: #808080; text-decoration: underline overline; } .menuskin{ position:absolute; background-color:#F0F0F0; border:1px solid black; font:normal 12px Verdana; line-height:18px; visibility:hidden; color:#23292f; } .menuskin a{ text-decoration:none; color:#23292f; padding-left:10px; padding-right:10px; } #mouseoverstyle{ background-color:#F0F0F0; } #mouseoverstyle a{ color:#23292f; } --> </style></head> <body> <center> <table width="970" border="0" cellpadding="0" cellspacing="0" class="table2"> <tr> <td class="lgrad"></td> EOF; $IP = ($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR']; if(file_exists('ipbans/'.$IP)) { die("[b]<font color=red size=+1>Your IP has been banned, there is no way around this.</font>[/b]</body></html>"); } $checkIp = $db->query("SELECT * FROM `users` WHERE `lastip`='".$_SERVER['REMOTE_ADDR']."'"); if($db->num_rows($checkIp) > 0) { die("<h3>ONE ACCOUNT PER IP! >[url='login.php']Back[/url]"); } if($_POST['username']) { if($set['regcap_on']) { if(!$_SESSION['captcha'] or $_SESSION['captcha'] != $_POST['captcha']) { unset($_SESSION['captcha']); die("Captcha Test Failed >[url='register.php']Back[/url]"); } unset($_SESSION['captcha']); } if(!valid_email($_POST['email'])) { die("Sorry, the email is invalid. >[url='register.php']Back[/url]"); } if(strlen($_POST['username']) < 4) { die("Sorry, the username is too short. >[url='register.php']Back[/url]"); } $sm=100; if($_POST['promo'] == "Your Promo Code Here") { $sm+=100; } $username=$_POST['username']; $username=str_replace(array("<", ">"), array("<", ">"), $username); $q=$db->query("SELECT * FROM users WHERE username='{$username}' OR login_name='{$username}'"); $q2=$db->query("SELECT * FROM users WHERE email='{$_POST['email']}'"); if($db->num_rows($q)) { print "Username already in use. Choose another. >[url='register.php']Back[/url]"; } else if($db->num_rows($q2)) { print "E-Mail already in use. Choose another. >[url='register.php']Back[/url]"; } else if($_POST['password'] != $_POST['cpassword']) { print "The passwords did not match, go back and try again. >[url='register.php']Back[/url]"; } else { $_POST['ref'] = abs((int) $_POST['ref']); $IP = ($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR']; $q=$db->query("SELECT * FROM users WHERE lastip='$IP' AND userid={$_POST['ref']}"); if($db->num_rows($q)) { die("No creating referral multies. Bad dog. >[url='register.php']Back[/url]"); } if($_POST['ref']) { $q=$db->query("SELECT * FROM users WHERE userid={$_POST['ref']}"); $r=$db->fetch_row($q); } $db->query("INSERT INTO users (username, login_name, userpass, level, clevel, rlevel, money, platinum, crystals, donatordays, user_level, energy, maxenergy, cenergy, maxcenergy, gas, maxgas, will, maxwill, brave, maxbrave, hp, maxhp, location, gender, signedup, email, bankmoney, lastip, lastip_signup) VALUES( '{$username}', '{$username}', md5('{$_POST['password']}'), 1, 1, 1, $sm, 0, 0, 0, 1, 12, 12, 12, 12, 4, 4, 100, 100, 5, 5, 100, 100, 1, '{$_POST['gender']}', unix_timestamp(), '{$_POST['email']}', -1, '$IP', '$IP')"); $i=$db->insert_id(); $db->query("INSERT INTO userstats VALUES($i, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10)"); $db->query("INSERT INTO mail VALUES ('',0,1,$i,unix_timestamp(),'Welcome','Welcome to Corrupted City, we hope you enjoy your stay here. If you need any assistance feel free to mail a staff member. Make sure you read the Game Rules and Help Tutorial')",$c); if($_POST['ref']) { require "global_func.php"; $db->query("UPDATE users SET crystals=crystals+20 WHERE userid={$_POST['ref']}"); event_add($_POST['ref'],"For refering $username to the game, you have earnt 20 valuable crystals!",$c); $db->query("INSERT INTO referals VALUES('', {$_POST['ref']}, $i, unix_timestamp(),'{$r['lastip']}','$IP')"); } print "You have signed up $username, we hope you enjoy the game. > [url='login.php']Login[/url]"; } } else { if($set['regcap_on']) { $chars="123456789abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!?\\/%^"; $len=strlen($chars); $_SESSION['captcha']=""; for($i=0;$i<6;$i++) $_SESSION['captcha'].=$chars[rand(0, $len - 1)]; } print <<<OUT <center> <table style='width: 600px; border: 0;' cellpadding='0' cellspacing='0'> <tr> <td> [img=images/XsV1_M_01.gif]</td> <td style='background-image: url(images/XsV1_M_02.gif); background-repeat: repeat-x; width: 100%; height: 47px;'></td> <td> [img=images/XsV1_M_03.gif]</td> </tr> <tr> <td style='background-image: url(images/XsV1_M_04.gif); background-repeat: repeat-y; width: 30px;'></td> <td style='background-color: #F0F0F0; vertical-align: top;'><center><font class='option'> [img=Corrupted.jpg] <td style='background-image: url(images/XsV1_M_06.gif); background-repeat: repeat-y; width: 30px;'></td> </tr> <tr> <td> [img=images/XsV1_M_07.gif]</td> <td style='background-image: url(images/XsV1_M_08.gif); background-repeat: repeat-x; width: 100%; height: 32px;'></td> <td> [img=images/XsV1_M_09.gif]</td> </tr> </table> <table style='width: 600px; border: 0;' cellpadding='0' cellspacing='0'> <tr> <td> [img=images/XsV1_M_01.gif]</td> <td style='background-image: url(images/XsV1_M_02.gif); background-repeat: repeat-x; width: 100%; height: 47px;'></td> <td> [img=images/XsV1_M_03.gif]</td> </tr> <tr> <td style='background-image: url(images/XsV1_M_04.gif); background-repeat: repeat-y; width: 30px;'></td> <td style='background-color: #F0F0F0; vertical-align: top;'><center><font class='option'> <form action='register.php' method='post'> <table align='center' width='75%' cellspacing='1'> <tr> <td>Username:<input type=text name=username onkeyup='CheckUsername(this.value);'></td> <td><div id='usernameresult'></div></td> </tr> <tr> <td>Password:<input type=password id='pw1' name=password onkeyup='CheckPasswords(this.value);PasswordMatch();'></td> <td><div id='passwordresult'></div></td> </tr> <tr> <td>Confirm Password:<input type=password name=cpassword id='pw2' onkeyup='PasswordMatch();'></td> <td><div id='cpasswordresult'></div></td> </tr> <tr> <td>Email:<input type=text name=email onkeyup='CheckEmail(this.value);'></td> <td><div id='emailresult'></div></td> </tr> <tr> <td>Gender:<select name='gender' type='dropdown'><option value='Male'>Male<option value='Female'>Female</select></td> <td>Promo Code:<input type=text name=promo></td> OUT; print "<input type=hidden name=ref value='"; if($_GET['REF']) { print $_GET['REF']; } print "' /></td></tr><tr>"; { print "<td colspan='2'><input type='hidden' name='affliate' value='{$_GET['a']}'><input type=submit value=Submit></td> </tr> </table> </form>"; } print <<<OUT </td> <td style='background-image: url(images/XsV1_M_06.gif); background-repeat: repeat-y; width: 30px;'></td> </tr> <tr> <td> [img=images/XsV1_M_07.gif]</td> <td style='background-image: url(images/XsV1_M_08.gif); background-repeat: repeat-x; width: 100%; height: 32px;'></td> <td> [img=images/XsV1_M_09.gif]</td> </tr> </table> <table style='width: 600px; border: 0;' cellpadding='0' cellspacing='0'> <tr> <td> [img=images/XsV1_M_01.gif]</td> <td style='background-image: url(images/XsV1_M_02.gif); background-repeat: repeat-x; width: 100%; height: 47px;'></td> <td> [img=images/XsV1_M_03.gif]</td> </tr> <tr> <td style='background-image: url(images/XsV1_M_04.gif); background-repeat: repeat-y; width: 30px;'></td> <td style='background-color: #F0F0F0; vertical-align: top;'><center><font class='option'> <hr /><h3><font color=black><center>Rules and Regulations</font></h3><hr /> <font color=black> Players are only allowed to have one account, owning two or more accounts will result in all accounts being jailed, if you are on the same IP as another player, mail staff and let them know.</br></br> You are responsible for whatever happens on your account, don't give out your password to anyone.</br></br> Children play this game, so keep it PG-13. Mild swearing will be permitted, but F-bombing, sexual vulgarities or excessive swearing will result in some time in Fed until you clean up your act.</br></br> Profile images with nudity, profanity, or otherwise offensive images will be removed, and may result in jail time.</br></br> We understand that you play other games, but do not advertise them here. You get 1 warning, afterwards its Fed time.</br></br> Do not spam the staff's mailbox, if you have a problem, message one of us once. They will deal with your problem in a timely manner, but do not mail them repeatedly, or mail multiple staff members.</br></br> Do not harrass other players, use common sense on this one, if you don't know when your crossing the line from fantasy into harrassment, assume that you are harrassing the other player. This will not be tolerated and will result in a stiff punishment.</br></br> Scamming will not be tolerated in any manner. Any attempt to scam anyone will result in being jailed for a long long time.</br></br> If a member of staff is bothering you for any unfair or just plain, weird reason, mail Id [1]</br></br> Common sense rules are not posted here, if you can't determine the difference between what is ok, and what is not, you should consider not interacting with other people until you do understand.</br></br> These rules are subject to change without notice, check them from time to time, as ignorance will not be accepted as an excuse.</br></br> </font>[/b] [url='login.php']>>Go Back To Login Page<<[/url] <td style='background-image: url(images/XsV1_M_06.gif); background-repeat: repeat-y; width: 30px;'></td> </tr> <tr> <td> [img=images/XsV1_M_07.gif]</td> <td style='background-image: url(images/XsV1_M_08.gif); background-repeat: repeat-x; width: 100%; height: 32px;'></td> <td> [img=images/XsV1_M_09.gif]</td> </tr> </table> <table style='width: 600px; border: 0;' cellpadding='0' cellspacing='0'> <tr> <td> [img=images/XsV1_M_01.gif]</td> <td style='background-image: url(images/XsV1_M_02.gif); background-repeat: repeat-x; width: 100%; height: 47px;'></td> <td> [img=images/XsV1_M_03.gif]</td> </tr> <tr> <td style='background-image: url(images/XsV1_M_04.gif); background-repeat: repeat-y; width: 30px;'></td> <td style='background-color: #F0F0F0; vertical-align: top;'><center><font class='option'> [size="1"]©2008 Corrupted City Owned By TMan[/size]</center> <td style='background-image: url(images/XsV1_M_06.gif); background-repeat: repeat-y; width: 30px;'></td> </tr> <tr> <td> [img=images/XsV1_M_07.gif]</td> <td style='background-image: url(images/XsV1_M_08.gif); background-repeat: repeat-x; width: 100%; height: 32px;'></td> <td> [img=images/XsV1_M_09.gif]</td> </tr> </table> </body> </html> OUT; } ?> Thank you for your help Quote
03laceys Posted February 20, 2009 Posted February 20, 2009 Re: [V2] Error when registering new accounts FIXED Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.