Walker33 Posted April 21, 2011 Share Posted April 21, 2011 I think I know the answer to this, but it would make things easier if I could do what I think I can't. Can I use LIKE and NOT LIKE in an if statement? Doesn't seem to be working for me. <?php //$rightlic is a twelve character string ending either P00, P01, V00, or V01. I want to do different things based on V or P if ($rightlic not like '%V00' AND $rightlic not like '%V01'){ echo "<br>purchaser ran demo as public but is now trying to purchase a private account. Stop the process."; exit; } ?> Can I do something like this or do I have to separate the string and look for the last characters that way? Thanks in advance for any help. Link to comment https://forums.phpfreaks.com/topic/234373-like-and-not-like-in-an-if-statement/ Share on other sites More sharing options...
mens Posted April 21, 2011 Share Posted April 21, 2011 No it wouldn't, PHP doesn't support SQL statements. Look at strstr() or preg_match(). Link to comment https://forums.phpfreaks.com/topic/234373-like-and-not-like-in-an-if-statement/#findComment-1204560 Share on other sites More sharing options...
Walker33 Posted April 21, 2011 Author Share Posted April 21, 2011 Okay, thanks. I didn't think so, but I wanted to be sure, and I couldn't find a definitive answer anywhere. Appreciate it. Link to comment https://forums.phpfreaks.com/topic/234373-like-and-not-like-in-an-if-statement/#findComment-1204562 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.