burgo855 Posted June 14, 2012 Share Posted June 14, 2012 Hi, Hopefully i can get some help on this. Basically i have made a script that generates a pin. But since using a new webhost half of the script doesn't seem to work. Its only generating the first three parts: <?php header("Content-Type: application/force-download"); header("Content-Disposition:attachment;filename=pin"); header("Content-Length: 28"); echo '0000001002' . date("Ymd") .("0011") .randomNumber(06); function randomNumber($length) { $str = ''; for ($i=0; $i < $length; $i++) { $str .= rand(0,9); } return $str; } The random 6 numbers do not seem to generate? Does anyone know why this new host is making the scripts random number generation fail? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/264155-php-script-failing-on-new-host/ Share on other sites More sharing options...
scootstah Posted June 14, 2012 Share Posted June 14, 2012 I'm not sure what would cause it to fail, but you don't need that function to generate a random 6 digit number. You can use this instead: echo '0000001002' . date("Ymd") .("0011") .rand(100000,999999); Quote Link to comment https://forums.phpfreaks.com/topic/264155-php-script-failing-on-new-host/#findComment-1353720 Share on other sites More sharing options...
burgo855 Posted June 15, 2012 Author Share Posted June 15, 2012 Must be something running in the background that alters it with the new host. Ill have to ask them. I had the random number like that because i guess i made this script when learning php... Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/264155-php-script-failing-on-new-host/#findComment-1354051 Share on other sites More sharing options...
insidus Posted June 15, 2012 Share Posted June 15, 2012 Is the PHP version the same as your previous host? Quote Link to comment https://forums.phpfreaks.com/topic/264155-php-script-failing-on-new-host/#findComment-1354092 Share on other sites More sharing options...
HDFilmMaker2112 Posted June 15, 2012 Share Posted June 15, 2012 Shouldn't be a issue, but try placing the function before it's called. Generally you should be able to place a function anywhere and have it work, but worth a try. Quote Link to comment https://forums.phpfreaks.com/topic/264155-php-script-failing-on-new-host/#findComment-1354094 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.