I'm trying to write a script to archive the last month's new user registrations that are timestamped which will hopefully be triggered by a cron job.

I'm using PHP and MySQL version 3.23.55 which doesn't support a bunch of useful functions to process date strings like STR_TO_DATE (post v4.1). So I'm wondering how is this done with the older versions? I'm having a really hard time finding documentation. I've done a lot of error checking and I've narrowed it down to the WHERE conditional. It's actually succeeding in creating the file but it's not pulling only the users from the last month. It's pulling all the users.

Thanks in advance.

- - - -

<?php

$now_Y=date("Y");
$now_m=date("m");
$min=date("Ym")."01";
$max=date("Ym")."32";
$start=

$dir="/usr/local/apache/htdocs/SOMEDIR";

$sql="SELECT * INTO OUTFILE "
."'$dir"."users_"."$now_Y"."-"."$now_m".".csv'"
." FIELDS TERMINATED BY ','"
." OPTIONALLY ENCLOSED BY '\"'"
." FROM sn_users"
." WHERE (('$min'<=`created`) <= '$max')";

$res=mysql_query($sql) or die('Error');

?>