|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Hi all,
I'm trying to figure out how to update a MySQL record (a single row) I cuurently have this but it isn't working... I'm just getting that error "0 is not a mysql result index...." or just the DIE result. mysql_db_query("guru", "INSERT INTO newslinks (clicks) values('$iClicks') WHERE id='$id'") or DIE("Unable to insert into database"); $id is a value from an auto_increment col, so it might be "34" or something. Therefore I want a command to tell Mysql to go to the row with id number "34" and update the col on that row with $iClicks. Thanks heaps for your time, Billy |
|
#2
|
||||
|
||||
|
"INSERT INTO newslinks (clicks) values('$iClicks') WHERE id='$id'" it should be: "INSERT INTO newslinks (clicks) values('$iClicks') WHERE id=$id" no need to put single quote for auto increment field. also make sure that your field names are correct..(ie, clicks) ------------------ SR - shiju.dreamcenter.net "The fear of the LORD is the beginning of knowledge..." [This message has been edited by Shiju Rajan (edited June 03, 2000).] |
|
#3
|
|||
|
|||
|
The proper syntax for what you are trying to do is:
update newslinks set clicks='$iClicks' where id=$id Insert is for new records. |
![]() |
| Viewing: Dev Shed Forums > Databases > MySQL Help > Updating a MySQL record |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|