you have changed the command from when you do it in mysql to when you do it
in php - you are leaving out the "'" quote marks around the date you are
passing :)

//   $sql="SELECT TO_DAYS(2001-01-01) AS bar";
should be
//   $sql="SELECT TO_DAYS('2001-01-01') AS bar";

HTH

beau


// -----Original Message-----
// From: Garry Optland [mailto:[EMAIL PROTECTED]]
// Sent: Friday, 1 February 2002 2:12 PM
// To: [EMAIL PROTECTED]
// Subject: [PHP-DB] More Date operations.
// 
// 
// Hi,
// 
// I am trying to access the MySQL function TO_DAYS() from PHP.
// 
// From MySQL I can type in: SELECT TO_DAYS('2000-1-1') AS bar;
// 
// and I get:
// 
// +--------+
// | bar    |
// +--------+
// | 730485 |
// +--------+
// 1 row in set (0.00 sec)
// 
// From PHP, I have tried:
// 
//   $sql="SELECT TO_DAYS(2001-01-01) AS bar";
//   $result=mysql_query($sql) or die("Could not access database");
//   $days=mysql_fetch_array($result);
//   echo "days: ".$days["bar"]."<br>";
// 
// But I don't get the result coming through.
// 
// I have tried mysql_field_name and the name comes across as "bar".
// 
// mysql_num_rows shows that there is one row in the result. 
// 
// Am I missing something really really obvious? 
// 
// Regards,
//     Garry.
// 
// 
// 
// -- 
// PHP Database Mailing List (http://www.php.net/)
// To unsubscribe, e-mail: [EMAIL PROTECTED]
// For additional commands, e-mail: [EMAIL PROTECTED]
// To contact the list administrators, e-mail: 
// [EMAIL PROTECTED]
// 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to