SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2012
    Posts
    99
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    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

    PHP 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']}, \n  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()}";
                                } 

  2. #2
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    limt_resutls 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, mysql camelcase table column names, 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.

  3. #3
    SitePoint Enthusiast
    Join Date
    Apr 2012
    Posts
    99
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    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

  4. #4
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    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


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •