afaaro Posted January 14, 2014 Share Posted January 14, 2014 (edited) 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, ))"); Edited January 14, 2014 by afaaro Quote 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) )"; Quote 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...
Solution afaaro Posted January 14, 2014 Author Solution Share Posted January 14, 2014 (edited) Woooow Thats amazing Psycho Thank you so much Edited January 14, 2014 by afaaro Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.