[PHP] converting a char variable to an int?

2004-06-14 Thread Adam Williams
Hi, I have a variable that is created using the date command:

$date = date(Ymd);

but its not working in my database this way (when I explicity enter 
20040614 in my database, it works though).  so I think PHP is making $date 
a character variable, so how can I force or change the caste of $date to 
force it to be an integer variable?  thanks

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] converting a char variable to an int?

2004-06-14 Thread Adam Williams
eh nevermind, I found settype();

:) thanks

On Mon, 14 Jun 2004, Adam Williams wrote:

 Hi, I have a variable that is created using the date command:
 
 $date = date(Ymd);
 
 but its not working in my database this way (when I explicity enter 
 20040614 in my database, it works though).  so I think PHP is making $date 
 a character variable, so how can I force or change the caste of $date to 
 force it to be an integer variable?  thanks
 
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] converting a char variable to an int?

2004-06-14 Thread Dennis Seavers
You could cast the type when you create the variable:

$variable = (integer) $variable;

Or you could set the type:

settype ($variable, integer);

However, the problem may be with the database, depending on what you mean
by it's not working in my database this way.


 [Original Message]
 From: Adam Williams [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Date: 06/14/2004 8:32:18 AM
 Subject: [PHP] converting a char variable to an int?

 Hi, I have a variable that is created using the date command:

 $date = date(Ymd);

 but its not working in my database this way (when I explicity enter 
 20040614 in my database, it works though).  so I think PHP is making
$date 
 a character variable, so how can I force or change the caste of $date to 
 force it to be an integer variable?  thanks

 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] converting a char variable to an int?

2004-06-14 Thread Marek Kilimajer
Does it work now?
It should not matter, because if you use $date in your sql statement:
$sql = update table set `date` = '$date';
$date is converted (back) to string.
Adam Williams wrote --- napĂ­sal::
eh nevermind, I found settype();
:) thanks
On Mon, 14 Jun 2004, Adam Williams wrote:

Hi, I have a variable that is created using the date command:
$date = date(Ymd);
but its not working in my database this way (when I explicity enter 
20040614 in my database, it works though).  so I think PHP is making $date 
a character variable, so how can I force or change the caste of $date to 
force it to be an integer variable?  thanks

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php