Invalid parameter number: parameter was not defined,

Hey there,

i am dealing with a “Invalid parameter number: parameter was not defined” i have triple checked the # of priamiters and their name, but that does not mean i am not missing something.

Here’s the block of code


$query = 'INSERT INTO users (
							   					   `email`,
   												   `password`,
   												   `dateJoined`,
   												   `farmName`,
   												   `limt_resutls`,
   												   `level`,
   												   `recive_email`,
   												   `salt1`,
  												   `salt2`
                                                 ) VALUES (
                                                    :email,
                                                    :password,
                                                    :datejoined,
                                                    :farmname,
                                                    :limt_resutls,
                                                    :level,
                                                    :recive_email,
                                                    :salt1,
                                                    :salt2
                                                 ) ';
							$values = array(
								'email' => $clean->text($_POST['email']),
								'password' => $clean->text($_POST['password']),
								'datejoined' => date('j-n-o'),
								'farmname' => $clean->text($_POST['farmname']),
								'limt_results' => '15',
								'level' => '2',
								'recive_email' => $_POST['reciveEmail'],
								'salt1' => $salt['2'],
								'salt2' => $salt['1'] );

							try {
								$insert = $pdo->prepare($query);
								$insert->execute($values);
							echo "Hello {$_POST['name']}, \
  your account has been created! you can login with {$_POST['email']} and your correct password";								
							} catch (PDOException $e) {
								echo "We could not insert the data into the database due to the error:: {$e->getMessage()}";
							}

limt_resutls :wink: You missed that.

The problem is down to you not having a variable naming convention. Either use underscore separated words, or all lower case or all CamelCase or hungarian notation or whatever you want - but be consistent everywhere and you will reduce the chances of making this kind of error.

And if you are going to use English then at least spell everything correctly (receive) and forget the affliction where you think you might be saving yourself some CPU cycles by making real words shorter (“limt” is that short for limit?), else, don’t be afraid to use your mother tongue.

$recive_email? Why use that at all, why not just $email? Even English speakers get mixed up about spelling “receive”, use a simpler word.

Start in your db, [google]mysql camelcase table column names[/google], and then be consistent in maintaining a scheme which spreads through your PHP code and into your HTML forms. The benefits beyond comprehensibility will become clear when you finally start to understand that you can loop through code as easy as you loop through arrays.

English is my mother tounge thanks… I have an NLD. $recive_email is an optional “do you want to recive email” type of deal, that’s why i do not use $email

I’m sorry if my last reply came across as a bit preachy and I did not mean to insult you, but really, “receive” is spelt like that.

I’m honestly trying to help you from making more work for yourself (and us) wading through errors purely caused by misspellings and inconsistencies.

There is nothing wrong with your code, you just need to be more rigorous with your naming.

It all counts as coding and its a mistake we’ve all made when starting out :wink: