The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> 2.00609119313E+13
CodeKing
post Sep 12 2006, 05:08 PM
Post #1


Advanced Member
****

Group: Members
Posts: 175
Joined: 12-September 06
Member No.: 118



In the following code doesn't work. It's suppose to delete users who haven't confirmed their account within 24 hours.

<?
$dbh=mysql_connect ("localhost", "mostmojo_mojo", "*********") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("mostmojo_members");
print($signtime = date("YmdHis")-240000);
$query = "DELETE FROM `users` WHERE `confirm`='0' AND `signtime`<'".$signtime."'";
if (!mysql_query($query))
{
print(mysql_error());
}
mysql_close($dbh);
?>

$signtime outputs as 2.00609119313E+13. Is that the reason it doesn't work? If you need any info about the database, just ask.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Sep 13 2006, 07:28 AM
Post #2


Jocular coder
********

Group: Members
Posts: 2,212
Joined: 31-August 06
Member No.: 43



QUOTE(CodeKing @ Sep 13 2006, 07:08 AM) *

In the following code doesn't work. It's suppose to delete users who haven't confirmed their account within 24 hours.

<?
$dbh=mysql_connect ("localhost", "mostmojo_mojo", "*********") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("mostmojo_members");
print($signtime = date("YmdHis")-240000);
$query = "DELETE FROM `users` WHERE `confirm`='0' AND `signtime`<'".$signtime."'";
if (!mysql_query($query))
{
print(mysql_error());
}
mysql_close($dbh);
?>

$signtime outputs as 2.00609119313E+13. Is that the reason it doesn't work? If you need any info about the database, just ask.


In what format do you write the signup time to the DB? Using date("YmdHis")? This seems extravagant - and gives you *enormous* pseudo-numbers to subtract, which may lead to problems with floating point overflow and goodness knows what. Why not just throw away the minutes and seconds, and record to the nearest hour? Notice that the value above is 2006-09-11 @ 9313, except that 9313 is not an obvious time.

Why are there _three_ different sorts of quotes in the MySQL query?


--------------------
Brian Chandler
Nothing in this post constitutes "commercial solicitation". PayPal does not solicit residents of Japan. Contents may settle in transit. "Legal mind" may or may not be brain-damaged.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Sep 13 2006, 07:59 AM
Post #3


Jocular coder
********

Group: Members
Posts: 2,212
Joined: 31-August 06
Member No.: 43



QUOTE(Brian Chandler @ Sep 13 2006, 09:28 PM) *

QUOTE(CodeKing @ Sep 13 2006, 07:08 AM) *

In the following code doesn't work. It's suppose to delete users who haven't confirmed their account within 24 hours.

<?
$dbh=mysql_connect ("localhost", "mostmojo_mojo", "*********") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("mostmojo_members");
print($signtime = date("YmdHis")-240000);
$query = "DELETE FROM `users` WHERE `confirm`='0' AND `signtime`<'".$signtime."'";
if (!mysql_query($query))
{
print(mysql_error());
}
mysql_close($dbh);
?>

$signtime outputs as 2.00609119313E+13. Is that the reason it doesn't work? If you need any info about the database, just ask.


In what format do you write the signup time to the DB? Using date("YmdHis")? This seems extravagant - and gives you *enormous* pseudo-numbers to subtract, which may lead to problems with floating point overflow and goodness knows what.


"Goodness knows what" includes the fact that the arithmetic doesn't work, because subtract causes the wrong sort of carry.

Suppose now is (in some time zone)
200609130615

Presumably you'd like people to be chopped if their signup time was before
200609120615

But the following sum gives a different answer *NEED MONOSPACE FONT*
20060913061500
_______-240000
20060912821500

So the chop will come at midnight on the day you sign up.

You can do date arithmetic using the time() function (what utterly _stupid_ names) to create a unix datestamp for the right value, then convert to the format above using date(). Look in the manual for helpful examples. Note that you will then have to untangle the mess created by MySQL using server local time vs Unix timestamps. I suggest that even if you _say_ "24 hours", it's simpler to delete them at the end of the day after signup.

HTH Smilies in batch mode: cool.gif sleep.gif ohmy.gif glare.gif angry.gif


--------------------
Brian Chandler
Nothing in this post constitutes "commercial solicitation". PayPal does not solicit residents of Japan. Contents may settle in transit. "Legal mind" may or may not be brain-damaged.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 30th July 2014 - 10:10 AM