Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

DATE_FORMAT Parse Error

New Here ,
Feb 20, 2008 Feb 20, 2008
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
TOPICS
Server side applications
370
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 20, 2008 Feb 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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 21, 2008 Feb 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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 21, 2008 Feb 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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 21, 2008 Feb 21, 2008
LATEST
.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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines