DamienRoche Posted July 28, 2008 Share Posted July 28, 2008 Hi guys. I'm having a few problems with this script. $unique_id = rand(100000000,999999999); Everything works (the random number is generated & inserted into MySQL db) but I can't figure out how to prefix the random number with text. I've changed the field the number inserts into in the db to a varchar. I've tried: $unique_id = "prefix"&rand(100000000,999999999); //to no avail Any thoughts? Thanks, Damien. Link to comment https://forums.phpfreaks.com/topic/116956-prefixing-a-random-number-using-rand/ Share on other sites More sharing options...
waynew Posted July 28, 2008 Share Posted July 28, 2008 $unique_id = $unique_id."TEXT"; Link to comment https://forums.phpfreaks.com/topic/116956-prefixing-a-random-number-using-rand/#findComment-601437 Share on other sites More sharing options...
DamienRoche Posted July 28, 2008 Author Share Posted July 28, 2008 Just sussed it!! I love php <3 Any way, in case any one else is interested..here's how: $unique_id .= "prefix"; $unique_id .= rand(1000000000,9999999999); Notice the period before the equals. Hope this helps someone. Link to comment https://forums.phpfreaks.com/topic/116956-prefixing-a-random-number-using-rand/#findComment-601445 Share on other sites More sharing options...
DamienRoche Posted July 28, 2008 Author Share Posted July 28, 2008 $unique_id = $unique_id."TEXT"; Thanks, that way may come in handy in the future. Appreciate it. Link to comment https://forums.phpfreaks.com/topic/116956-prefixing-a-random-number-using-rand/#findComment-601451 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.