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 Quote Link to comment 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; } ?> Quote Link to comment Share on other sites More sharing options...
Canman2005 Posted April 22, 2007 Author Share Posted April 22, 2007 Spot on mate, nice one Quote Link to comment 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.