stijn0713 Posted August 22, 2012 Share Posted August 22, 2012 something really weird: i make a password like this: $passcode = rand().time(). i use this pasword in an email that i send to users and i write away the inactive subscription. Now, i see in mysql that the pasword is always the same: 2147483647. I figured out that it was not the code but because of int(11). But, the strange part is that in the mail: $message = sprintf("$message", $paswoord); $mail = mail($email_respondent_on, 'subject', $message) is also says: 2147483647. Is it possible that the mail function is also configured with max variable size equal to int(11). if so, where do i check that? Quote Link to comment https://forums.phpfreaks.com/topic/267429-size-variable/ Share on other sites More sharing options...
Jessica Posted August 22, 2012 Share Posted August 22, 2012 You went from $passcode to $paswoord. What happens between those lines? Quote Link to comment https://forums.phpfreaks.com/topic/267429-size-variable/#findComment-1371474 Share on other sites More sharing options...
ialsoagree Posted August 22, 2012 Share Posted August 22, 2012 These are only temporary passwords right? As rand and time are not good ways of generating passwords... Regardless, try: $passcode = rand() . time(); Also, if your database is limited to an int 11, realize you can only generate a random number between 0 and 9 to prefix it with, because time() will generate a number 10 digits long, leaving you with only 1 digit from rand, so you should probably call rand(0,9) or just increase the size of your column to at least int(15). You should also make sure you limit the length of the variable sent in the e-mail, since if it's longer it won't match your database. Quote Link to comment https://forums.phpfreaks.com/topic/267429-size-variable/#findComment-1371476 Share on other sites More sharing options...
Jessica Posted August 22, 2012 Share Posted August 22, 2012 These are only temporary passwords right? As rand and time are not good ways of generating passwords... Regardless, try: $passcode = rand() . time(); He's already doing that. Also, if your database is limited to an int 11, realize you can only generate a random number between 0 and 9 to prefix it with, because time() will generate a number 10 digits long, leaving you with only 1 digit from rand, so you should probably call rand(0,9) or just increase the size of your column to at least int(15). You should also make sure you limit the length of the variable sent in the e-mail, since if it's longer it won't match your database. Int 11 does not mean an 11 digit long int. The range of an int (11) depends on if it is signed or unsigned, but either way the upper limit is only 10 digits and if you try to add a 9 to the front of a 10 digit number, that's too big for int (11). http://dev.mysql.com/doc/refman/5.0/en/integer-types.html if you don't believe me, you need to learn what binary means. Quote Link to comment https://forums.phpfreaks.com/topic/267429-size-variable/#findComment-1371477 Share on other sites More sharing options...
ialsoagree Posted August 22, 2012 Share Posted August 22, 2012 He's already doing that. No, not quite: echo 1 . 2; //prints the string "12" echo 1.2; //prints the number 1.2 Int 11 does not mean an 11 digit long int. The range of an int (11) depends on if it is signed or unsigned, but either way the upper limit is only 10 digits and if you try to add a 9 to the front of a 10 digit number, that's too big for int (11). http://dev.mysql.com/doc/refman/5.0/en/integer-types.html if you don't believe me, you need to learn what binary means. Wow, okay, yes, you are correct. I was thinking of char and often mix up the two column size methods! Quote Link to comment https://forums.phpfreaks.com/topic/267429-size-variable/#findComment-1371478 Share on other sites More sharing options...
Jessica Posted August 22, 2012 Share Posted August 22, 2012 Your example is irrelevant. We're not dealing with a number 1.2, we're dealing with numbers returned by a function. Run this. <?php echo time() . time(); echo '<br>'; echo time().time(); ?> My output was: 13456577201345657720 13456577201345657720 Furthermore, if you do this: <?php echo rand() . time(); echo '<br>'; echo rand().time(); ?> You should get something LIKE this: 164691345657793 313381345657793 rand() . time() IS THE SAME as rand().time(); 1 . 2 vs. 1.2 is different. PHP assumes you MEAN 1.2. When you have two functions concatenated, you can ONLY mean concatenation. Quote Link to comment https://forums.phpfreaks.com/topic/267429-size-variable/#findComment-1371480 Share on other sites More sharing options...
ialsoagree Posted August 22, 2012 Share Posted August 22, 2012 I'm just attempting to be thorough. I don't have access to run his code atm. Regardless, you seem to have this, so I shall move along. Quote Link to comment https://forums.phpfreaks.com/topic/267429-size-variable/#findComment-1371481 Share on other sites More sharing options...
Mahngiel Posted August 22, 2012 Share Posted August 22, 2012 With all the users you may have and the various amount of surveys that are possible to exist, it's quite likely your mail server could get tagged as a spammer. 10 users with 10 different surveys to take = 100 emails. Something to keep in mind. Quote Link to comment https://forums.phpfreaks.com/topic/267429-size-variable/#findComment-1371482 Share on other sites More sharing options...
aliento Posted August 22, 2012 Share Posted August 22, 2012 Hello, In this case i debug by echo $password, after any line i use $password and i see where changes to fix it. Quote Link to comment https://forums.phpfreaks.com/topic/267429-size-variable/#findComment-1371491 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.