Problem with inserting data into mysql database

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
nigmsoft
Forum Newbie
Posts: 1
Joined: Sun Oct 11, 2009 1:43 am

Problem with inserting data into mysql database

Post by nigmsoft »

Hi,Everyone
Now I have wrote a sql text for inserting some data into the database

Code: Select all

 
'INSERT INTO `smf`.`smf_members` (`memberName`, `realName`, `passwd`, `emailAddress`, `address`, `phone`, `mobile`, `gender`, `signature`) VALUES (`$UName`,`$RealName`,`$Pass`,`$Email`,`$Address`,`$Phone`,`$Mobile`,`$GenderType`,`$Signature`);'
 
Then i got this error message
MatchQuery failed: Unknown column '$UName' in 'field list'
you must knew that $UName is a php variable and it isn't a field in the database table called 'smf_members'
what is the wrong with mysql text ?

plz help me as soon as possible
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: Problem with inserting data into mysql database

Post by Eric! »

It looks like the editor you're using to enter this query is changing the quotes for you. You need to have single quotes around your query items

Code: Select all

"INSERT INTO 'smf'.'smf_members' ('memberName', 'realName', 'passwd', 'emailAddress', 'address', 'phone', 'mobile', 'gender', 'signature') VALUES ('$UName','$RealName','$Pass','$Email','$Address','$Phone','$Mobile','$GenderType','$Signature');"
Post Reply