General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 16th, 2003, 07:32 PM
punkrawkpat punkrawkpat is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: Australia
Posts: 4 punkrawkpat User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 30 m 46 sec
Reputation Power: 0
Angry Update Query Doesnt Work

I am using an update query to update records in my mysql database using the values entered into text fields on a form. I have captured the ID of the record, which is passed to my update script, and the update data loads correctly. However, once the update is submitted, the data seems to be sent correctly, but the update makes no changes to the record. I know the database connection works, as I've entered phony values and it errors. However, the mysql_affected_rows function shows that no records were updated. My code is below, starting at the actual update query, as the rest seems fine. Any help would be appreciated.

mysql_connect("host","user","pass");
@mysql_select_db(joke) or die( "Unable to connect database");
$sql= "UPDATE joke
SET JokeText='JokeText',
SubmittedBy='SubmittedBy',
SubmitterMail='SubmitterMail',
JokeDate='JokeDate' WHERE ID='ID'";
mysql_query($sql) or die( '<p> Unable to update record: ' .
mysql_error() .'</p>');
printf ("Records Updated: %d\n", mysql_affected_rows());
echo "Record Updated";
mysql_close();
?>

Reply With Quote
  #2  
Old December 16th, 2003, 09:32 PM
thecharking thecharking is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 187 thecharking User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via AIM to thecharking
okay so I may be way off, but... are the thigns being passed in actually variables? don't they need to be:

PHP Code:
//I'm assuming you have done this...
$jokeText $_POST['jokeText'];
$submittedBy $_POST['submittedBy'];

SET JokeText='$JokeText'
SubmittedBy='$SubmittedBy',... 


and so on.
am I off here?
__________________
hey it's the CHARKING

Reply With Quote
  #3  
Old December 17th, 2003, 07:07 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
Right, and if these strings are just test values but you don't have an id "ID," no update will occur.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Update Query Doesnt Work


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 3 hosted by Hostway
Stay green...Green IT