Canman2005 Posted April 22, 2007 Share Posted April 22, 2007 Hi I have a function that creates a random string, the function looks like <?php function randomkeys($length) { $pattern = "1234567890abcdefghijklmnopqrstuvwxyz"; for($i=0;$i<$length;$i++) { $key .= $pattern{rand(0,35)}; } return $key; } ?> The function has worked fine until the server guys did some changes to the server, now when you include the function, you get the error Notice: Undefined variable: key in C:\www\mysite\functions\rand.php on line 7 Does anyone know why this is happening? Thanks Ed Link to comment https://forums.phpfreaks.com/topic/48162-solved-random-function/ Share on other sites More sharing options...
genericnumber1 Posted April 22, 2007 Share Posted April 22, 2007 they probably upp'd the error level to NOTICE, this error has always been there, just not shown.. do <?php function randomkeys($length) { $key = ''; $pattern = "1234567890abcdefghijklmnopqrstuvwxyz"; for($i=0;$i<$length;$i++) { $key .= $pattern{rand(0,35)}; } return $key; } ?> Link to comment https://forums.phpfreaks.com/topic/48162-solved-random-function/#findComment-235446 Share on other sites More sharing options...
Canman2005 Posted April 22, 2007 Author Share Posted April 22, 2007 Spot on mate, nice one Link to comment https://forums.phpfreaks.com/topic/48162-solved-random-function/#findComment-235447 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.