Jump to content

[SOLVED] MYSQL CASE statement within PHP syntax or correct quoting ?


listman100

Recommended Posts

Hi I'm trying to use a MySQL "CASE" statement within PHP to develop a conditional query.  The query runs fine within from the MySQL command prompt with the "case" statements.  And the PHP code works fine when I remove the lines that begin with "case".  However when I run the query as listed below within my PHP code i get the following:

 

 

[Fri Apr 20 22:15:24 2007] [error] [client 10.188.50.74] PHP Parse error:  parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /srv/www/htdocs/mysql-learn/acetrack-post.php on line 68, referer: http://webserver1/mysql-learn/acetrack-post.html

 

 

< code snip >

 

$query  ="

SELECT

  acetitle, tracking_no, aceamt,

  case when (To_days(curdate()) - To_days(create_date)) >= 90 Then pototalamt else "" end  as  "90past" ,

  case when (To_days(curdate()) - To_days(create_date)) < 90 and (To_days(curdate()) - To_days(create_date)) > 30 Then pototalamt else "" end  as "30-90past"

  FROM Purtable t

LEFT JOIN acelog a

ON ace=acenum

WHERE ace='0220'

        GROUP by po ASC

        ";

 

  $result = mysql_query($query);

 

< /code snip >

 

 

Thanks in advance for any help.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.