I'm having a strange issue that I'm sure has a reasonable answer, but it's making me nuts.
I am using the code below, but no matter what I do, on the host's server it displays the created_date as '0000-00-00 00:00:00'. I get the correct response locally. If I go to the server and run a query in phpmyadmin it returns fine, if I run it locally it works fine.
Local version: 5.1.37
Server version: 5.0.96-community
Is there so much different between these versions that the code below won't work?
$data = mysql_query("select id, created_date, title
from posts
ORDER by id DESC") or die(mysql_error());
$num = mysql_num_rows($data);
while($info = mysql_fetch_array( $data ))
{
$postid = $info['id'];
$created_date = $info['created_date'];
$title = $info['title'];
}
echo 'postid: ' . $postid;
echo '<br />';
echo 'created_date: ' . $created_date;
echo '<br />';
echo 'title: ' . $title;
echo '<br />';
Here is what I get from the echo command:
postid: 16
created_date: 0000-00-00 00:00:00
title: New Site Design
but the following is expected
postid: 16
created_date: 2012-12-10 21:45:00
title: New Site Design
Table code:
CREATE TABLE IF NOT EXISTS `posts` (
`id` int(11) NOT NULL auto_increment,
`created_date` timestamp NOT NULL default CURRENT_TIMESTAMP,
`modified_date` datetime NOT NULL,
`author_id` int(11) NOT NULL,
`title` varchar(250) NOT NULL,
`content` longtext NOT NULL,
`excerpt` mediumtext NOT NULL,
`image_filename` varchar(150) NOT NULL,
`status` varchar(150) NOT NULL,
`category` varchar(500) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=263 ;
--
-- Dumping data for table `posts`
--
INSERT INTO `posts` (`id`, `created_date`, `modified_date`, `author_id`, `title`, `content`, `excerpt`, `image_filename`, `status`, `category`) VALUES
(16, '2012-12-15 09:45:00', '2012-12-15 04:45:00', 5, 'New Site Design', '<p>I''m starting to setup the new site design. Unfortunately I stayed with the Worpress design too long and not only did it get stale, but it got hacked which is common. It''s not that they have poor security, but since everyone uses them, it''s inevitable that someone will break into your site. Hopefully my custom job will be better anyway. <a href="www.paulille.com">Testing Link</a></p>', '', 'testimage200.png', 'active', 'Website');
Any help is much appreciated. Thank you in advance.