listman100 Posted April 21, 2007 Share Posted April 21, 2007 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. Quote Link to comment Share on other sites More sharing options...
bubblegum.anarchy Posted April 21, 2007 Share Posted April 21, 2007 pretty much just replace the internal double quotes with single quotes. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.