www.webdeveloper.com
Results 1 to 6 of 6

Thread: [RESOLVED] Inserting into Database with error Unknown Column in field List.

  1. #1
    Join Date
    Jun 2009
    Location
    Chi town. IL68 ICAO code home airport, literally.
    Posts
    153

    resolved [RESOLVED] Inserting into Database with error Unknown Column in field List.

    Well I have this really stupid issue. I am not sure as to what is going on, but here is my issue.

    Once someone confirms their account, I am automatically taking the information from the first database, retreving it, and then sending it off to other databases to write information and create login info.

    My issue is this error

    PHP Code:
    [28-Nov-2012 21:53:46] array ( => '42S22'=> 1054=> 'Unknown column \'myusername\' in \'field list\'', ) 
    This leads me to belevie that it is having an issue with inserting the username into the username field.

    Could it be that since the variable is named exactly like the feild entry it is having an issue?

    Here is the code.
    PHP Code:
    //connects to picture database and writes your info in there.
        
    try {
        
    $wpdb = new PDO('mysql:host=localhost; dbname=harcerze_pictures''harcerze_super''Boeing07');
        
    $wpdb->setAttribute(PDO::ATTR_ERRMODEPDO::ERRMODE_EXCEPTION);
                                                                
                     
    //Creates the SQL statement to write into the picture database
            
    $pictureUPDATE $wpdb->prepare
            
    ("INSERT INTO pe_users (
                      username,
            password,
            groupID
            ) VALUES (
            
    $username,
            
    $passmd5,
            
    $groupID
                                   )"
    );
                                                                
        
    //Executes the writing into the picture database
                 
    $pictureUPDATE->execute();
    echo(
    "<p>Your account to upload photos is now active!</p>");            
    }
        
    //catches any errors that might have come from updating the picture databse
        
    catch (PDOException $ex) {
        
    $msg $ex->errorInfo;
        
    error_log(var_export($msgtrue));
        die(
    "<p>Sorry, there was a unrecoverable database error with PICTURES.  Debug data has been logged.</p>");
                } 
    For want of a nail...the horseshoe was lost. For want of a horseshoe, the steed was lost. For want of a steed...the message was not delivered. For want of an undelivered message.....the war was lost.

  2. #2
    Join Date
    Nov 2006
    Location
    Oakland
    Posts
    500
    The error message 'Unknown column \'myusername\' in \'field list\' clearly show that there is no myusername column in the target database table.

    The following SQL statement suggests that its you should try "username" instead of myusername.
    $pictureUPDATE = $wpdb->prepare ("INSERT INTO pe_users (username, password, groupID)
    VALUES ($username, $passmd5, $groupID)

  3. #3
    Join Date
    Jun 2009
    Location
    Chi town. IL68 ICAO code home airport, literally.
    Posts
    153
    Well if you look at my code, thats exactly what I have written...the same SQL statement that you have.
    For want of a nail...the horseshoe was lost. For want of a horseshoe, the steed was lost. For want of a steed...the message was not delivered. For want of an undelivered message.....the war was lost.

  4. #4
    Join Date
    Nov 2006
    Location
    Oakland
    Posts
    500
    Where is the error message generated from?

    You should make a global "find" of the word "myusername". Your code does not show such a variable or string anywhere.

  5. #5
    Join Date
    Mar 2009
    Posts
    452
    you need to add quotes to your variables like this...

    Code:
    $pictureUPDATE = $wpdb->prepare ("INSERT INTO pe_users (username, password, groupID) 
    VALUES ('{$username}', '{$passmd5}', '{$groupID}')

  6. #6
    Join Date
    Jun 2009
    Location
    Chi town. IL68 ICAO code home airport, literally.
    Posts
    153
    ZABI!!! Thats great! Thanks so much! Works like a charm, the moment I was typing it I saw the varibles lightup white and I knew it was going to work! THANKS!
    For want of a nail...the horseshoe was lost. For want of a horseshoe, the steed was lost. For want of a steed...the message was not delivered. For want of an undelivered message.....the war was lost.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles