Jump to content

Where is the error?


cvo

Recommended Posts

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 ;

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.