cvo Posted July 28, 2008 Share Posted July 28, 2008 if ($doing == "registor") { $password = $_POST['password']; $password = md5($password ); $email=$_POST['email']; $lname=$_POST['lname']; $fname=$_POST['fname']; $rank="cdt"; srand ((double) microtime( )*1000000); $random_number = rand(1000000,9999999); $date = "0000-00-00 00:00:00"; $about="Nothing Much"; $zero="0"; $query = "INSERT INTO users VALUES ('','$random_number','$rank','$fname','$lname',NOW(),'$date','$zero','$zero','$zero','$about','$email','$password')"; if (!mysql_query($query)){ $works = "0"; }else{ $works="1"; } } Ive tried fixing this, but its not telling me what the error is and is still not inserting in the database. can anyone spot any errors there. Thanks in advance... Just incase, here is a dump of the users table... CREATE TABLE IF NOT EXISTS `users` ( `id` bigint(20) NOT NULL auto_increment, `randomId` int(11) NOT NULL, `rank` text NOT NULL, `fname` text NOT NULL, `lname` text NOT NULL, `dateRegisored` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, `lastOn` timestamp NOT NULL default '0000-00-00 00:00:00', `banned` bigint(20) NOT NULL default '0', `bannedHours` bigint(20) NOT NULL default '0', `banCount` bigint(20) NOT NULL default '0', `about` longtext NOT NULL, `email` text NOT NULL, `password` text NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ; Quote Link to comment Share on other sites More sharing options...
dannyb785 Posted July 28, 2008 Share Posted July 28, 2008 You need to specify which columns each variables is being assigned to. or else it wont know where you want them. So you need to do: $query = "INSERT INTO users (user_id, user_number, _user_rank, user_fname, etc etc...) VALUES ('','$random_number','$rank','$fname','$lname',NOW(),'$date','$zero','$zero','$zero','$about','$email','$password')"; But the number of items in the first parenthesis must be the same number in the second. Quote Link to comment Share on other sites More sharing options...
Pyro Posted July 28, 2008 Share Posted July 28, 2008 Could it be your spelling of Register? "registor" as the button to register, may have a different id name to what you are queriing. sorry for mis spelling Quote Link to comment Share on other sites More sharing options...
cvo Posted July 28, 2008 Author Share Posted July 28, 2008 Thanks dannyb785, still no luck though. $query = "INSERT INTO users (id, randomId, rank, fname, lname, dateRegisored, lastOn, banned, bannedHours, banCount, about, email, password) VALUES ('','$random_number','$rank','$fname','$lname',NOW(),'$date','$zero','$zero','$zero','$about','$email','$password')"; and Pyro thats just a bad spelling habit sorry, but any how here is my form ish. <form action="index.php?page=registor" method="Post"><input name="lname" type="hidden" value="<?=$_POST['lname'] ?>"><input name="fname" type="hidden" value="<?=$_POST['fname'] ?>"><input name="password" type="hidden" value="<?=$_POST['password'] ?>"><input name="email" type="hidden" value="<?=$_POST['email'] ?>"><input type="submit" value="FINNISH"><input type="hidden" name="part" value=3><input name="doing" type="hidden" value="registor"></form> Edit: Wrong form sorry that was an earlier one Quote Link to comment Share on other sites More sharing options...
Pyro Posted July 28, 2008 Share Posted July 28, 2008 you have no id on you input, that may be a reason why it is not working, on the imput put: id="registor" just before the ">" and that may help this is on your register button Quote Link to comment Share on other sites More sharing options...
cvo Posted July 28, 2008 Author Share Posted July 28, 2008 Im sure the form works perfictly becouse it runs the sql query, the query just fails and doesnt insert the data. Quote Link to comment Share on other sites More sharing options...
Pyro Posted July 28, 2008 Share Posted July 28, 2008 oh ok, im still a amature at php, but from what i can see, you have not set it to update the sql and set the users information in the correct rows. darkwater knows lots of php pm him. sorry that i can not be much more help. Quote Link to comment Share on other sites More sharing options...
dannyb785 Posted July 28, 2008 Share Posted July 28, 2008 Im sure the form works perfictly becouse it runs the sql query, the query just fails and doesnt insert the data. You need to add "or die(mysql_error());" after your query. Change the end part to just: $result = mysql_query($query) or die(mysql_error()); that will help you with what is going wrong. There is also a worse problem and thats you do not need to insert the literal id into your database in the user_id column. If it's set to auto_increment then just leave it alone, it'll do it on its own. Quote Link to comment Share on other sites More sharing options...
cvo Posted July 28, 2008 Author Share Posted July 28, 2008 man, sorry everyone, definite armature mistake. I forgot to include my database connecting file. Man I hate it when you spend all night writing and it ends up being something so simple. Thanks everyone Quote Link to comment Share on other sites More sharing options...
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.