Jump to content

[SOLVED] I am trying to insert random MD5 into multiple rows at a time..


sedolan

Recommended Posts

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

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.

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` =*; 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.