Jump to content

Select Case help


kemnet

Recommended Posts

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

Link to comment
Share on other sites

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.

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.