More Date operations.
| From: | Garry Optland | Date: | Fri, 01 Feb 2002 06:11:48 +0000 |
| Subject: | More Date operations. | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-16382@lists.php.net to get a copy of this message | ||
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.