Skip to main content
Participating Frequently
February 20, 2008
Question

DATE_FORMAT Parse Error

  • February 20, 2008
  • 4 replies
  • 374 views
Hello,

PHP/MySQL Application....

How would I use the DATE_FORMAT function in a table that uses $row. Here is my code:

<td align="left">' . $row['date_received'] . '</td>

I've tried this:

<td align="left">' . $row(DATE_FORMAT(['date_received']), '%m %d %y') . '</td>

but receive parse error message:

Parse error: parse error, unexpected '[', expecting ')' on line 214

Thank you for your help.

William
This topic is closed to new replies. Start a new post to keep the conversation going.

4 replies

Inspiring
February 21, 2008
.oO(Joe Makowiec)

>Yes, except pick some word other than 'date':
>
>$query = "SELECT name, DATE_FORMAT(date_received, '%m/%d/%y') AS
>myDate....
>
>'date' is frequently a keyword - it is in MySQL, and, without looking,
>probably in PHP too. Many apps don't like if you use keyword for
>something other than their intended use.

Good point, even if it doesn't matter much in this case. It works in
MySQL and PHP doesn't care at all about any reserved names in array
indexes.

Micha
Inspiring
February 21, 2008
On 20 Feb 2008 in macromedia.dreamweaver.appdev, WPW07 wrote:

> I think I may have resolved the problem. I needed to use
> DATE_FORMAT in the Select Statement above the table:
>
> $query = "SELECT name, DATE_FORMAT(date_received, '%m/%d/%y') AS
> date....
>
> Then in the table, use
>
> <td align="left">' . $row['date'] . '</td>

Yes, except pick some word other than 'date':

$query = "SELECT name, DATE_FORMAT(date_received, '%m/%d/%y') AS
myDate....

'date' is frequently a keyword - it is in MySQL, and, without looking,
probably in PHP too. Many apps don't like if you use keyword for
something other than their intended use.

--
Joe Makowiec
http://makowiec.net/
Email: http://makowiec.net/contact.php
Inspiring
February 21, 2008
.oO(WPW07)

>I think I may have resolved the problem. I needed to use DATE_FORMAT in the
>Select Statement above the table:
>
> $query = "SELECT name, DATE_FORMAT(date_received, '%m/%d/%y') AS date....
>
> Then in the table, use
>
> <td align="left">' . $row['date'] . '</td>

Correct. ;)

Micha
WPW07Author
Participating Frequently
February 20, 2008
I think I may have resolved the problem. I needed to use DATE_FORMAT in the Select Statement above the table:

$query = "SELECT name, DATE_FORMAT(date_received, '%m/%d/%y') AS date....

Then in the table, use

<td align="left">' . $row['date'] . '</td>

William