/    Sign up×
Community /Pin to ProfileBookmark

[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

[code=php]
[28-Nov-2012 21:53:46] array ( 0 => ’42S22′, 1 => 1054, 2 => ‘Unknown column ‘myusername’ in ‘field list”, )
[/code]

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.

[code=php]
//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_ERRMODE, PDO::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($msg, true));
die(“<p>Sorry, there was a unrecoverable database error with PICTURES. Debug data has been logged.</p>”);
}
[/code]

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@holyhttpNov 29.2012 — 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)
Copy linkTweet thisAlerts:
@UAL225authorNov 29.2012 — Well if you look at my code, thats exactly what I have written...the same SQL statement that you have.
Copy linkTweet thisAlerts:
@holyhttpNov 29.2012 — 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.
Copy linkTweet thisAlerts:
@ZABINov 29.2012 — 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}')
[/CODE]
Copy linkTweet thisAlerts:
@UAL225authorNov 29.2012 — 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!
Copy linkTweet thisAlerts:
@cmtJan 02.2019 — thank u so much ZABI..
×

Success!

Help @UAL225 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.10,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...