Jump to content

size variable


stijn0713

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.