afaaro Posted January 14, 2014 Share Posted January 14, 2014 I have got this one but it's only working with small letters and numbers, how can i make both lower case and upper case and numbers as well. this is the query am using right now dbquery("UPDATE ".CATEGORY." SET category_url=CONCAT(LOWER(SUBSTRING((CONV(SUBSTRING(RAND(), 3), 10, 36)), 1, ))"); Link to comment https://forums.phpfreaks.com/topic/285367-i-need-help-with-generating-random-string/ Share on other sites More sharing options...
Psycho Posted January 14, 2014 Share Posted January 14, 2014 I would suggest creating the code in PHP. But the below will work. It's ugly, but will work. $query = "UPDATE " . CATEGORY . " SET category_url = CONCAT( SUBSTR('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', FLOOR(1+RAND()*62), 1), SUBSTR('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', FLOOR(1+RAND()*62), 1), SUBSTR('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', FLOOR(1+RAND()*62), 1), SUBSTR('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', FLOOR(1+RAND()*62), 1), SUBSTR('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', FLOOR(1+RAND()*62), 1), SUBSTR('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', FLOOR(1+RAND()*62), 1) )"; Link to comment https://forums.phpfreaks.com/topic/285367-i-need-help-with-generating-random-string/#findComment-1465243 Share on other sites More sharing options...
afaaro Posted January 14, 2014 Author Share Posted January 14, 2014 Woooow Thats amazing Psycho Thank you so much Link to comment https://forums.phpfreaks.com/topic/285367-i-need-help-with-generating-random-string/#findComment-1465245 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.