DrDamnit
asked on
strtotime returns -1 for a real date!
I have a class (user) which has a property (users_expiration_date)
In this procedure, strtotime always evaluates to -1, and I don't understand why:
$xUser = new users;
$xUser->users_id = $_POST['uid'];
$xUser->load_me();
if(isset($_POST['password' ]))
{
echo "Password updated.";
$xUser->users_pass = md5($_POST['password']);
}
if(isset($_POST['xdate']))
{
$xUser->users_expiry_date = $_POST['xdate'];
}
if(isset($_POST['radioAdmi n']))
{
$xUser->users_is_admin = $_POST['radioAdmin'];
}
$xUser->update_me();
Here is the code for update_me():
function update_me()
{
$sql = "UPDATE `users` SET `users_name` = '$this->users_name', `users_pass` = '$this->users_pass', `users_expiry_date` = FROM_UNIXTIME(". strtotime($this->users_exp iry_date). "), `users_is_admin` = '$this->users_is_admin', `contacts_id` = '$this->contacts_id' WHERE `users_id` = '$this->users_id' LIMIT 1";
$this->execute_query($sql) ;
}
Here are the POST values:
User Administration
Array
(
[username] => jerri
[xdate] => 12/31/3000
[radioAdmin] => N
[Modules] => Array
(
[56] => N
[26] => N
[42] => N
[1] => N
[40] => N
[19] => N
[32] => N
[8] => N
[12] => Y
[7] => Y
[49] => N
[24] => N
[29] => N
[10] => N
[30] => N
[25] => N
[50] => N
[28] => N
[43] => N
[54] => N
[21] => N
[34] => N
[17] => N
[47] => N
[41] => N
[33] => N
[14] => N
[20] => N
[23] => N
[9] => N
[46] => N
[38] => N
[53] => N
[11] => N
[51] => Y
[31] => N
[44] => N
[52] => N
[15] => N
[5] => N
[55] => Y
[58] => Y
)
[Submit] => Update
[stage] => 3
[uid] => 49
)
Here is user after the values have been assigned:
users Object
(
[users_id] => 49
[users_name] => jerri
[users_pass] => 0fc54732b7e737b5ed770a7335 baa398
[users_expiry_date] => 12/31/3000
[users_is_admin] => N
[users_unix_timestamp_xdat e] => 0
[contacts_id] => 2934
)
Here's the resulting SQL that is executed for MySQL:
UPDATE `users` SET `users_name` = 'xxxxx', `users_pass` = '0fc54732b7e737b5ed770a733 5baa398', `users_expiry_date` = FROM_UNIXTIME(-1), `users_is_admin` = 'N', `contacts_id` = '2934' WHERE `users_id` = '49' LIMIT 1
Does anyone see why this is not evaluating to a unix timestamp?
In this procedure, strtotime always evaluates to -1, and I don't understand why:
$xUser = new users;
$xUser->users_id = $_POST['uid'];
$xUser->load_me();
if(isset($_POST['password'
{
echo "Password updated.";
$xUser->users_pass = md5($_POST['password']);
}
if(isset($_POST['xdate']))
{
$xUser->users_expiry_date = $_POST['xdate'];
}
if(isset($_POST['radioAdmi
{
$xUser->users_is_admin = $_POST['radioAdmin'];
}
$xUser->update_me();
Here is the code for update_me():
function update_me()
{
$sql = "UPDATE `users` SET `users_name` = '$this->users_name', `users_pass` = '$this->users_pass', `users_expiry_date` = FROM_UNIXTIME(". strtotime($this->users_exp
$this->execute_query($sql)
}
Here are the POST values:
User Administration
Array
(
[username] => jerri
[xdate] => 12/31/3000
[radioAdmin] => N
[Modules] => Array
(
[56] => N
[26] => N
[42] => N
[1] => N
[40] => N
[19] => N
[32] => N
[8] => N
[12] => Y
[7] => Y
[49] => N
[24] => N
[29] => N
[10] => N
[30] => N
[25] => N
[50] => N
[28] => N
[43] => N
[54] => N
[21] => N
[34] => N
[17] => N
[47] => N
[41] => N
[33] => N
[14] => N
[20] => N
[23] => N
[9] => N
[46] => N
[38] => N
[53] => N
[11] => N
[51] => Y
[31] => N
[44] => N
[52] => N
[15] => N
[5] => N
[55] => Y
[58] => Y
)
[Submit] => Update
[stage] => 3
[uid] => 49
)
Here is user after the values have been assigned:
users Object
(
[users_id] => 49
[users_name] => jerri
[users_pass] => 0fc54732b7e737b5ed770a7335
[users_expiry_date] => 12/31/3000
[users_is_admin] => N
[users_unix_timestamp_xdat
[contacts_id] => 2934
)
Here's the resulting SQL that is executed for MySQL:
UPDATE `users` SET `users_name` = 'xxxxx', `users_pass` = '0fc54732b7e737b5ed770a733
Does anyone see why this is not evaluating to a unix timestamp?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.