[SOLVED] Add to mysql table

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
cmetzke
Forum Newbie
Posts: 6
Joined: Mon Sep 06, 2004 2:35 pm

[SOLVED] Add to mysql table

Post by cmetzke »

Hi all,
Im trying to add to a specifc mysql table colom but cant seem to get it right.
IE:

Code: Select all

$confirm = $query="insert into registration SET Confirm='Yes' Username='$UserName'";

$confirm = $query="UPDATE registration SET Confirm='Yes' Username='$UserName'";
To me this says insert into the table "registration" in a colom called Confirm The Word Yes But only into the one where the username matches(which is what i am trying to do). But niether of these seem to work for me.
Any Ideas ? :D
Last edited by cmetzke on Tue Sep 14, 2004 9:12 am, edited 1 time in total.
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

You need to check the SQL syntax...

For Insertion (New row)

Code: Select all

INSERT INTO table ї(column1,column2...)] VALUES (value1,value2...);
so in your case it would be

Code: Select all

INSERT INTO  registration (Confirm,Username) VALUES ('Yes','$UserName');
Updates are normally appended with a WHERE condition.

Code: Select all

UPDATE registration SET Confirm='Yes' WHERE Username='$UserName';
Next...

You have not shown how you connect to the database for processing. If not done then nothing will work anyway. You will need to go and look that up (try a web search for PHP MySQL if that is the database you are using).
cmetzke
Forum Newbie
Posts: 6
Joined: Mon Sep 06, 2004 2:35 pm

Post by cmetzke »

Hey Thanks very very much appreciated :D That Worked like a charm.
Post Reply