sedolan Posted October 29, 2009 Share Posted October 29, 2009 Server version: 5.0.58-log MySQL client version: 4.1.22 UPDATE `gameadds_maxadds`.`users` SET `remove` = MD5(uniqid(rand(), true)) WHERE `users`.`id` =*; Error SQL query: UPDATE `gameadds_maxadds`.`users` SET `remove` = MD5( uniqid( rand( ) , true ) ) MySQL said: Documentation #1305 - FUNCTION gameadds_maxadds.uniqid does not exist CREATE TABLE `users` ( `id` int(11) NOT NULL auto_increment, `email` varchar(255) NOT NULL, `active` varchar(32) NOT NULL, `game` varchar(255) NOT NULL, `remove` varchar(32) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=516 DEFAULT CHARSET=latin1 So basically all I am trying to do is replace all the data that's in the remove column with new unique random md5 data, since this option was implemented later on in our coding progress I have multiple rows that currently have no md5 data in the remove field. Thanks in advance, -Sean Quote Link to comment https://forums.phpfreaks.com/topic/179446-solved-i-am-trying-to-insert-random-md5-into-multiple-rows-at-a-time/ Share on other sites More sharing options...
cags Posted October 29, 2009 Share Posted October 29, 2009 You appear to be attempting to use uniqid as a MySQL function, I've searched the documentation and no such function seems to exist (though I've never liked their documentation), it would appear that MySQL has assumed it is a column name in your table. Quote Link to comment https://forums.phpfreaks.com/topic/179446-solved-i-am-trying-to-insert-random-md5-into-multiple-rows-at-a-time/#findComment-947004 Share on other sites More sharing options...
sedolan Posted October 29, 2009 Author Share Posted October 29, 2009 I kinda figured that I was doing it wrong... do you or anyone else know how to do what I am trying to do? -Sean Quote Link to comment https://forums.phpfreaks.com/topic/179446-solved-i-am-trying-to-insert-random-md5-into-multiple-rows-at-a-time/#findComment-947112 Share on other sites More sharing options...
kickstart Posted October 29, 2009 Share Posted October 29, 2009 Hi Just to confirm, are you trying to add a different MD5 hash into each row that you update? Or just one single unique MD5 for all the rows updated in that statement? All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/179446-solved-i-am-trying-to-insert-random-md5-into-multiple-rows-at-a-time/#findComment-947207 Share on other sites More sharing options...
Philip Posted October 29, 2009 Share Posted October 29, 2009 UPDATE `gameadds_maxadds`.`users` SET `remove` = MD5(uniqid(rand(), true)) WHERE `users`.`id` =*; Those are all PHP functions, so I'm guessing thats what you meant to do - one unique for the whole set? $sql = "UPDATE `gameadds_maxadds`.`users` SET `remove` = '".MD5(uniqid(rand(), true))."' WHERE `users`.`id` =*"; If you want to do it purely mysql, and generate a random result each time: UPDATE `gameadds_maxadds`.`users` SET `remove` = MD5(RAND()) WHERE `users`.`id` =*; Quote Link to comment https://forums.phpfreaks.com/topic/179446-solved-i-am-trying-to-insert-random-md5-into-multiple-rows-at-a-time/#findComment-947296 Share on other sites More sharing options...
sedolan Posted October 29, 2009 Author Share Posted October 29, 2009 Thanks KingPhilip!, UPDATE `gameadds_maxadds`.`users` SET `remove` = MD5(RAND()); Did the trick! -Sean Quote Link to comment https://forums.phpfreaks.com/topic/179446-solved-i-am-trying-to-insert-random-md5-into-multiple-rows-at-a-time/#findComment-947433 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.