Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parse error : T_CONSTANT_ENCAPSED_STRING

Status
Not open for further replies.

Copierbw

Technical User
Sep 25, 2002
112
IE
Can somone please help me out please..
I have this MYSql query..
SELECT DATE_FORMAT(Date,'%M %d %Y'), filedetails.In FROM filedetails
WHERE filedetails.In='N'

Which gives the desired results.

But when I echo <?php echo ['DATE_FORMAT(Date,'%r %M %d %Y')']; ?> in my page I get this error &quot;Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ']' in c:\apache&quot;
 
You have single quotes inside single quotes.

Assuming you are trying to output the string &quot;[DATE.....]&quot;, then you should escape the inner single quotes with backslashes.

Something like:

<?php echo ['DATE_FORMAT(Date,\'%r %M %d %Y\')']; ?> ______________________________________________________________________
TANSTAAFL!
 
DATE_FORMAT is a mysql function not a PHP function, you should either :
a) use date_format(date_field, options) in your query and then just echo the output
or
b) once you have run your query , use the PHP function mktime() to format the field.

see:
and
(about halfway down the page) ______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top