l3asturd Posted August 1, 2007 Share Posted August 1, 2007 ok, I'm trying to UPDATE a row based on the username. So, I assume to code looks something like: <?php $update_result = mysql_query(UPDATE $dbtable SET $dbtable.Score = "Updated Score" FOR ($dbtable.Name =($POST_['Username'])); ?> Now I realize this is probably completely way off, but this is how I have interpreted that it should be done. So, I type in a username, and in theory, it should UPDATE the usernames score to "Updated Score" right? Someone please explain how this is SUPPOSED to be done? Quote Link to comment https://forums.phpfreaks.com/topic/62953-solved-update-for-field/ Share on other sites More sharing options...
chronister Posted August 1, 2007 Share Posted August 1, 2007 Almost, the proper syntax for an update query is $query="UPDATE tablename SET fieldname='$newvalue' WHERE fieldname='$fieldnamevar'"; $result=mysql_query($query); This is the general syntax. You should use an ID in the where clause so you get the correct record updated with minimal chances of error. Nate Quote Link to comment https://forums.phpfreaks.com/topic/62953-solved-update-for-field/#findComment-313464 Share on other sites More sharing options...
l3asturd Posted August 2, 2007 Author Share Posted August 2, 2007 genius, thanks! Quote Link to comment https://forums.phpfreaks.com/topic/62953-solved-update-for-field/#findComment-313610 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.