[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


mysql query returns blank value (Select max(datetime) from table)

Posted on 2008-11-09
Medium Priority
Last Modified: 2013-12-13
 I am using following mysql query to fetch the data and it displays a blank result when using my php code.  However it did return the value when i run it on mysql command window.

$sql = mysql_query("SELECT MAX( time ) FROM table")  or die(mysql_error());
$data = mysql_fetch_assoc($sql);
echo $data['time'];

Note: the time field has a datetime datatype in the table.

Question by:Shiva_Kumar

Accepted Solution

jamesgu earned 2000 total points
ID: 22916231
try this

$sql = mysql_query("SELECT MAX( time ) as max_time FROM table")  or die(mysql_error());
$data = mysql_fetch_assoc($sql);
echo $data['max_time'];

Author Closing Comment

ID: 31514822
Thanks buddy, it worked.

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month19 days, 20 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question