Forum Moderators: coopster

Message Too Old, No Replies

Problem w/date

PHP and date

         

NateNWI

1:45 pm on Mar 4, 2003 (gmt 0)

10+ Year Member



I'm having problem formatting a date. Users input their date of birth by selecting from 3 dropdown menus.

I keep getting Type Mismatch Errors when I use:

$datestamp = mktime(0,0,0,$Date,$Month,$Year);
$DOB = getdate($datestamp);

Any ideas?

Birdman

1:58 pm on Mar 4, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It looks like you have your date and month reversed in you mktime() [php.net] line.

NateNWI

2:10 pm on Mar 4, 2003 (gmt 0)

10+ Year Member



I see that mktime is a function for UNIX. What's the equivalent for Windows?

Paul in South Africa

2:14 pm on Mar 4, 2003 (gmt 0)

10+ Year Member



That's right mktime accepts upto six integer arguements in the order hour, minute, second, month, day of month, year.

andreasfriedrich

2:18 pm on Mar 4, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>>I see that mktime is a function for UNIX.
>>What's the equivalent for Windows?

The PHP [php.net] manual just says that mktime() [php.net] returns a UNIX timestamp, i.e. the seconds since 1970-01-01. It is still a PHP [php.net] function and implemented in all PHP [php.net] versions for all OSs.

Andreas

NateNWI

3:11 pm on Mar 4, 2003 (gmt 0)

10+ Year Member



Thanks for the help. It's still telling me there's a "Data type mismatch in criteria expression. Here's my code:

<?
$UserName = ""; # User Name
$DBpassword = ""; # Password
$DBName = ""; # Name of the database
$DataSource = ""; # Name of the DSN
$Table = ""; # Name of the table

$datestamp = mktime(0,0,0,$Month,$Date,$Year);
$DOB = getdate($datestamp);

$conn = odbc_connect("DSN=$DataSource;UID=$UserName;PWD=''","","");

If ($conn) {

$add = odbc_exec($conn , "
INSERT INTO $Table
(First_Name,
Last_Name,
Password,
DOB,
City,
State,
Country,)
VALUES
('$Fname',
'$Lname',
'$Password',
'$DOB',
'$City',
'$State',
'$Country',)
"
);

If ($add) {
echo "Sucess. Form uploaded to the database.";
odbc_close($conn);
}

Else
echo "The odbc_connect succeeded but the upload to the database failed." ;
}

Else
echo "Failure. The odbc_connect failed.";
?>

Thank You

andreasfriedrich

3:22 pm on Mar 4, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You might want to check whether $Month ($Date, $Year) is_integer() [php.net] as that is the data type that mktime() [php.net] expects. Turning register_globals of and using the $_GET or $_POST superglobal depending of the method you get the form data will make your script more secure.

Andreas