MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old June 2nd, 2000, 09:36 PM
billy_bill_1 billy_bill_1 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2000
Posts: 6 billy_bill_1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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


Reply With Quote
  #2  
Old June 3rd, 2000, 02:35 AM
Shiju Rajan's Avatar
Shiju Rajan Shiju Rajan is offline
.Net Developer
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2000
Location: London
Posts: 987 Shiju Rajan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 26 m 22 sec
Reputation Power: 9
Send a message via MSN to Shiju Rajan Send a message via Yahoo to Shiju Rajan

"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).]

Reply With Quote
  #3  
Old June 3rd, 2000, 04:56 AM
rod k rod k is offline
Apprentice Deity
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jul 1999
Location: Niagara Falls (On the wrong side of the gorge)
Posts: 3,237 rod k User rank is Private First Class (20 - 50 Reputation Level)rod k User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 m 8 sec
Reputation Power: 13
Send a message via AIM to rod k
The proper syntax for what you are trying to do is:

update newslinks set clicks='$iClicks' where id=$id

Insert is for new records.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > Updating a MySQL record


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway