Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-09-2012, 06:01 PM   PM User | #1
qwertyjjj
New Coder

 
Join Date: Dec 2007
Posts: 59
Thanks: 1
Thanked 0 Times in 0 Posts
qwertyjjj is an unknown quantity at this point
srand? Fatal error: Call to undefined function 1352483998() line 31

This code has worked for ages so am not sure what is wrong now.
Line 31 is the srand line:

Code:
//function
function generatePassword($length=6,$level=2){

   list($usec, $sec) = explode(' ', microtime());
   srand((float) $sec   ((float) $usec * 100000));

   $validchars[1] = "23456789abcdefghjkmnpqrstuvwxyz";
   $validchars[2] = "23456789abcdefghjkmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ";
   $validchars[3] = "23456789_!@#$%&*()-= /abcdefghjkmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ_!@#$%&*()-= /";

   $password  = "";
   $counter   = 0;

   while ($counter < $length) {
     $actChar = substr($validchars[$level], rand(0, strlen($validchars[$level])-1), 1);

     // All character must be different
     if (!strstr($password, $actChar)) {
        $password .= $actChar;
        $counter  ;
     }
   }

   return $password;

}
qwertyjjj is offline   Reply With Quote
Old 11-09-2012, 06:30 PM   PM User | #2
qwertyjjj
New Coder

 
Join Date: Dec 2007
Posts: 59
Thanks: 1
Thanked 0 Times in 0 Posts
qwertyjjj is an unknown quantity at this point
I added a + and now the script times out on this line:

while ($counter < $length) { $actChar = substr($validchars[$level], rand(0, strlen($validchars[$level])-1), 1);

Last edited by qwertyjjj; 11-09-2012 at 06:36 PM..
qwertyjjj is offline   Reply With Quote
Old 11-09-2012, 06:47 PM   PM User | #3
qwertyjjj
New Coder

 
Join Date: Dec 2007
Posts: 59
Thanks: 1
Thanked 0 Times in 0 Posts
qwertyjjj is an unknown quantity at this point
The error was my host's web editor saves the files and strips operators...at least strips the + operator from all code!!!!!
qwertyjjj is offline   Reply With Quote
Old 11-10-2012, 11:15 AM   PM User | #4
Dormilich
Senior Coder

 
Dormilich's Avatar
 
Join Date: Jan 2010
Location: Behind the Wall
Posts: 2,860
Thanks: 9
Thanked 290 Times in 286 Posts
Dormilich is on a distinguished road
Quote:
at least strips the + operator from all code!!!!!
if used in GET/POST, + is the replacement for a space character. your host’s web editor is just missing the escaping of sent content (I guess this is done through AJAX, as a regular form submit would take care of that).
__________________
please post your code wrapped in [CODE] [/CODE] tags
Dormilich is offline   Reply With Quote
Old 11-10-2012, 10:54 PM   PM User | #5
tangoforce
Senior Coder

 
tangoforce's Avatar
 
Join Date: Feb 2011
Location: Your Monitor
Posts: 3,496
Thanks: 44
Thanked 439 Times in 428 Posts
tangoforce will become famous soon enoughtangoforce will become famous soon enough
Quote:
Originally Posted by qwertyjjj View Post
The error was my host's web editor saves the files and strips operators...at least strips the + operator from all code!!!!!
So keep your dev files locally, edit in notepad++ and upload via FTP.
__________________
Please wrap your code in [php] tags. It is a sticky topic and it HELPS us to HELP YOU!
TIP: Coding styles and $end errors :::::::::: TIP: Warning: Cannot modify header information - headers already sent :::::::::: TIP: Quotes / Parse error: syntax error, unexpected T_..
PHP Code:
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value. 
Explanation: The IE if(isset($_POST['submit'])) bug explained.
tangoforce is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:20 PM.


Advertisement
Log in to turn off these ads.