corsasport.co.uk
 

Corsa Sport » Message Board » Off Day » Geek Day » More PHP fun...!


New Topic

New Poll
  Subscribe | Add to Favourites

You are not logged in and may not post or reply to messages. Please log in or create a new account or mail us about fixing an existing one - register@corsasport.co.uk

There are also many more features available when you are logged in such as private messages, buddy list, location services, post search and more.


Author More PHP fun...!
liamC
Member

Registered: 28th Feb 04
User status: Offline
24th Jan 07 at 19:36   View User's Profile U2U Member Reply With Quote

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
24th Jan 07 at 19:43   View User's Profile U2U Member Reply With Quote

you have to update not insert....
liamC
Member

Registered: 28th Feb 04
User status: Offline
24th Jan 07 at 19:46   View User's Profile U2U Member Reply With Quote

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
24th Jan 07 at 19:51   View User's Profile U2U Member Reply With Quote

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
24th Jan 07 at 19:56   View User's Profile U2U Member Reply With Quote

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
24th Jan 07 at 20:05   View User's Profile U2U Member Reply With Quote

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
24th Jan 07 at 20:13   View User's Profile U2U Member Reply With Quote

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
24th Jan 07 at 20:14   View User's Profile U2U Member Reply With Quote

Thats not the right syntax for an update statement.

Give me 2 mins.
liamC
Member

Registered: 28th Feb 04
User status: Offline
24th Jan 07 at 20:14   View User's Profile U2U Member Reply With Quote

cheers mate!
James
Member

Registered: 1st Jun 02
Location: Surrey
User status: Offline
24th Jan 07 at 20:15   View User's Profile U2U Member Reply With Quote

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
24th Jan 07 at 20:16   View User's Profile U2U Member Reply With Quote

too late...

[Edited on 24-01-2007 by aPk]
liamC
Member

Registered: 28th Feb 04
User status: Offline
24th Jan 07 at 20:20   View User's Profile U2U Member Reply With Quote

Chaps, you are all stars. Muchos gracias.

 
New Topic

New Poll

  Related Threads Author Forum Replies Views Last Post
BoLtOn CrUiZeS PrincessxSexy Meets and Events 0 257
15th Dec 02 at 17:58
by PrincessxSexy
 
MORNING Tommy General Chat 25 839
7th May 03 at 10:53
by LoudandSlow
 
Hit a wall.:( mav General Chat 33 505
8th Sep 04 at 21:50
by mav
 
Few Pics from the Pod (56K Warning) PaulW General Chat 12 1058
21st Feb 05 at 16:40
by Jambo
 
Dodgy HTML/PHP/Table problem liamC Geek Day 9 778
24th Jan 07 at 19:37
by liamC
 

Corsa Sport » Message Board » Off Day » Geek Day » More PHP fun...! 29 database queries in 0.0112071 seconds