Seems as if I'm close
I have added the code to (in theory) make the changes to the correct tables/fields. Here is the code with my changes:
code:
error_reporting(E_ALL);
//Database Info
$dbhost = 'localhost';
$dbuser = 'xxxxx';
$dbpass = 'xxxxx';
$dbname = 'dbname';
// Open database connection
//
$link = mysql_connect($dbhost, $dbuser, $dbpass)
or die("Could not connect");
mysql_select_db($dbname)
or die("Could not select database");
$query = "select username,user_regdate from usersnuke";
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result))
{
$curruser = $row["username"];
$timestamp = date_str_to_unixtimestamp($row["user_regdate"], TRUE);
$query2="update phpbb_users set user_regdate = '$timestamp' WHERE username = '$curruser'";
$update_result = mysql_query($query2);
echo "Ran update query on user: $curruser with result: $update_result";
}
// test-data
//$date_strings = array(
// 'Nov. 10, 2001', 'Jun 10, 2002', 'Foo 10, 1999', 'x', '', 'Jan 32, 1999', 'Jan 10, badyear', 'jan 31, 1995', 'may 07, 2005'
//);
// perform test and display results
//foreach($date_strings as $date_string) {
// convert to timestamp
//$timestamp = date_str_to_unixtimestamp($date_string, TRUE);
// convert back to string (to make it easier to check result)
//$date_string2 = date('F j, Y', $timestamp);
//echo "'$date_string' => '$timestamp' => '$date_string2'\n";
//}
// Given date string 'MMM DD, YYYY', return unix timestamp.
//
// If date string is invalid:
// If $debug is omitted or FALSE, return 0.
// If $debug is present and TRUE, return 1 if syntax is bad, 2 if month name is bad, 3 if date is bad.
function date_str_to_unixtimestamp($date_string, $debug = FALSE) {
if (!preg_match('/^([a-z]+)\W+(\d+)\W+(\d+)$/i', $date_string, $matches)) {
return $debug ? 1 : 0;
}
$month = month_name_to_num($matches[1]);
if ($month === FALSE) {
return $debug ? 2 : 0;
}
$day = $matches[2];
$year = $matches[3];
if (!checkdate($month, $day, $year)) {
return $debug ? 3 : 0;
}
return mktime(12, 0, 0, $month, $day, $year);
}
// Given month name, return number 1..12.
// Return FALSE if name is not valid.
function month_name_to_num($month_name) {
static $months = array(
'jan' => 1, 'feb' => 2, 'mar' => 3, 'apr' => 4, 'may' => 5, 'jun' => 6,
'jul' => 7, 'aug' => 8, 'sep' => 9, 'oct' => 10, 'nov' => 11, 'dec' => 12
);
$num = @$months[strtolower($month_name)];
return isset($num) ? $num : FALSE;
}
//Close Database connection
//
mysql_close($link);
When I run that I get this:
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in blah/blah/blah/ on line xxI never said I was a php guru either
Thanks again for all the help!