kemnet Posted May 20, 2012 Share Posted May 20, 2012 Hello Forums. I have this query $mt = $this->db->prepare('SELECT id,type,rigFROM table WHERE form_name=?'); $mt->bind_param("s",$form_name); $mt->execute(); $mt->bind_result($id,$type,$rig); This works fine... but i want to say incase the current date is => expires date(which is a column) write expired or not expired to another column like this $mt = $this->db->prepare('SELECT id,type,rig,CASE WHEN CURDATE( ) >= `expires` THEN 'Expired'ELSE 'Not Expired'END AS status FROM table WHERE form_name=?'); $mt->bind_param("s",$form_name); $mt->execute(); $mt->bind_result($id,$type,$rig,$status); This code works fine in PHP admin but when i pull it onto my webscripts it doesnt seem to work...would love if someone could point out my error..thanks Quote Link to comment Share on other sites More sharing options...
Illusion Posted May 21, 2012 Share Posted May 21, 2012 That might be due to inappropriate single quotes. Try putting sql query in double quotes as you already have literal strings in single quotes with in query or use concatenation operator to build the query. Quote Link to comment Share on other sites More sharing options...
kemnet Posted May 21, 2012 Author Share Posted May 21, 2012 like thiS? ("SELECT id,type,rig,CASE WHEN CURDATE( ) >= `expires` THEN 'Expired'ELSE 'Not Expired'END AS status FROM table WHERE form_name=?"); Quote Link to comment Share on other sites More sharing options...
Illusion Posted May 21, 2012 Share Posted May 21, 2012 Yes. Does it work ? Quote Link to comment Share on other sites More sharing options...
kemnet Posted May 21, 2012 Author Share Posted May 21, 2012 actually what i did to get it to work was \'Expired\' thanks for setting me on the write path 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.