cs1h Posted August 20, 2008 Share Posted August 20, 2008 Hi, I have a table in mysql with codes in one column, I would now like to convert the codes to be md5 hashed. Is there a way to do it in one go (because I have about 1000 entries) so I don't have to go through them all one by one. Any help will be appreciated. Thanks, Colin Link to comment https://forums.phpfreaks.com/topic/120509-md5-encoding/ Share on other sites More sharing options...
Fadion Posted August 20, 2008 Share Posted August 20, 2008 I can't think of an automated way. What i can suggest is using a similar script: <?php $results = mysql_query("SELECT id, code FROM table"); while($values = mysql_fetch_array($results)){ $code = md5($values['code']); $id = $values['id']; $resultsUpdate = mysql_query("UPDATE table SET code='$code' WHERE id=$id"); } ?> Link to comment https://forums.phpfreaks.com/topic/120509-md5-encoding/#findComment-620977 Share on other sites More sharing options...
Mchl Posted August 20, 2008 Share Posted August 20, 2008 UPDATE table SET code = MD5(code); Link to comment https://forums.phpfreaks.com/topic/120509-md5-encoding/#findComment-620982 Share on other sites More sharing options...
Fadion Posted August 20, 2008 Share Posted August 20, 2008 UPDATE table SET code = MD5(code); lol. ok that is definitely better Link to comment https://forums.phpfreaks.com/topic/120509-md5-encoding/#findComment-620986 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.