liamC
Member
Registered: 28th Feb 04
User status: Offline
|
When the user edits the title and description I want it to REPLACE the current title and description in that particular row of the database table.
I have the following within my code under a _POST function:
code: $sql="INSERT INTO tblSO (fldTITLE,fldSO) values ('$fldTITLE','$fldSO') WHERE fldSOID = 1";
I get an error
As soon as I delete the WHERE fldSOID = 1 part of the code above the function works fine absolutely fine, but doesn't replace the current title and description, and instead adds the data as another row.
I tried switcing the code so it looked like this but still didn't have any luck:
code: $sql="INSERT INTO tblSO WHERE fldSOID = 1 (fldTITLE,fldSO) values ('$fldTITLE','$fldSO')";
Any ideas!!
|
AndyKent
Member
Registered: 3rd Sep 05
User status: Offline
|
you have to update not insert....
|
liamC
Member
Registered: 28th Feb 04
User status: Offline
|
Thanks mate!
As you can tell, I am a complete PHP/MYSQL n00b and learning as I go along!
I used the INSERT on another part of the database where it adds fields, hence how I thought it was the same!
[Edited on 24-01-2007 by liamC]
|
AndyKent
Member
Registered: 3rd Sep 05
User status: Offline
|
Thats ok - have to start somewhere
If you're going to do a lot of PHP/MySQL stuff I'd recommend you get a decent book - I bought one from Ottakars when I started and its excellent.......can't remember what its called though
|
liamC
Member
Registered: 28th Feb 04
User status: Offline
|
Cheers. I was looking on Amazon for PHP/MYSQL books earlier and I'll probably purchase one later on.
code: $sql="UPDATE tblSO (fldTITLE,fldSO) values ('$fldTITLE','$fldSO') WHERE fldSOID = 1";
Is the above right? I am still getting an error?
Do I need apostrophes around the 1 so it looks like '1'?
|
AndyKent
Member
Registered: 3rd Sep 05
User status: Offline
|
depends on the data type - if it is set as a number (int, double etc) then just 1 - if it is text (char, varchar etc) then it will need to be '1'
|
Tom J
Organiser: South Wales Premium Member
Registered: 8th Sep 03
Location: Bridgend
User status: Offline
|
i know its not related but does anyone know how to get rid of the subject box when posting a reply?
|
James
Member
Registered: 1st Jun 02
Location: Surrey
User status: Offline
|
Thats not the right syntax for an update statement.
Give me 2 mins.
|
liamC
Member
Registered: 28th Feb 04
User status: Offline
|
cheers mate!
|
James
Member
Registered: 1st Jun 02
Location: Surrey
User status: Offline
|
UPDATE tblSO SET fldTITLE= '$fldTITLE', fldSO= '$fldSO' WHERE fldSOID = 1
Try that.
[Edited on 24-01-2007 by James]
|
AndyKent
Member
Registered: 3rd Sep 05
User status: Offline
|
too late...
[Edited on 24-01-2007 by aPk]
|
liamC
Member
Registered: 28th Feb 04
User status: Offline
|
Chaps, you are all stars. Muchos gracias.
|