I'm using PHP to display a MySQL table. I've got everything working fine except the date function.

I designated the first two fields VARCHAR. Those columns display just fine when I preview my web page, as do all the other columns except the third. I designated that one DATE. (The field name is "Birthday.")

When I view my data in phpMyAdmin, all I see in that column is NULL. When I preview it in a webpage, nothing displays at all. If I change it to NOT NULL, I see 0000-00-00 in every cell.

Here's a row of text from the CSV file I imported into my MySQL table:

"Alberta","Edmonton","1905-09-01",11,"NWT","AB","CAN"

As you can see, the date is listed as "1905-09-01."

I've altered my MySQL table every way I can think of, and nothing works. The MySQL Manual doesn't shed any light on it. So I'm wondering if there's something wrong with my PHP code.

Below's the source code from my web page. Do you see anything that would cause the third column - echo $myrow["Birthday"]; - to malfunction, while everything else works fine?

Thanks.

<?php
$db = mysql_connect("localhost", "USERNAME", "PASSWORD");
mysql_select_db("test",$db);
$result = mysql_query("SELECT * FROM states",$db);
echo "<table>";
echo"<tr><td><b>Name</b><td><b>Capital</b><td><b>Birthday</b><td><b>Rank</b><b>Origin</b><b>Code</b><td><b>Nation</b></tr>";
while($myrow = mysql_fetch_array($result))
{
echo "<tr><td>";
echo $myrow["Name"];
echo "</td><td>";
echo $myrow["Capital"];
echo "</td><td>";
echo $myrow["Birthday"];
echo "</td><td>";
echo $myrow["Rank"];
echo "</td><td>";
echo $myrow["Origin"];
echo "</td><td>";
echo $myrow["Code"];
echo "</td><td>";
echo $myrow["Bigcode"];
echo "</td></tr>";
}
echo "</table>";
?>

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



Reply via email to