Page 1 of 1

[SOLVED] Add to mysql table

Posted: Tue Sep 14, 2004 7:58 am
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

Posted: Tue Sep 14, 2004 8:23 am
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).

Posted: Tue Sep 14, 2004 9:10 am
by cmetzke
Hey Thanks very very much appreciated :D That Worked like a charm.