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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.