Alison1 Posted August 9, 2012 Share Posted August 9, 2012 I need to know the best way to search a long string (under Registrations) that would appear like so '<a href="link.html">ADHS</a> <a href="link.html">AAPhC</a> <a href="link.html">ASEA</a>' etc. etc. Using PHP MyAdmin's 'Create PHP Code' I tried to start with $query = mysql_query( "SELECT * FROM `horses` WHERE `registrations` LIKE \'%ADHS%\'"); as a starting point, but it does not work when put into my existing code. I know the code works otherwise, because when I remove everything in the string but ADHS and search specifically for that, it works like a charm. I am not sure if it just doesn't like 'LIKE' Any suggestions? Hope I made sense! Quote Link to comment https://forums.phpfreaks.com/topic/266876-noob-in-need-of-help/ Share on other sites More sharing options...
Maq Posted August 9, 2012 Share Posted August 9, 2012 it does not work when put into my existing code What exactly does that mean? Do you receive errors, blank page, incorrect results, what? You shouldn't be escaping the single quotes in the like clause. You should also check for errors: $query = mysql_query( "SELECT * FROM `horses` WHERE `registrations` LIKE '%ADHS%'") or die(mysql_error()); You should also post more of the pertinent code. Quote Link to comment https://forums.phpfreaks.com/topic/266876-noob-in-need-of-help/#findComment-1368214 Share on other sites More sharing options...
Alison1 Posted August 10, 2012 Author Share Posted August 10, 2012 Thank you very much, the error reporting helped! I appreciate it Quote Link to comment https://forums.phpfreaks.com/topic/266876-noob-in-need-of-help/#findComment-1368408 Share on other sites More sharing options...
Maq Posted August 10, 2012 Share Posted August 10, 2012 You should actually be properly handling errors. One of the staff members wrote this article: http://www.phpfreaks.com/blog/or-die-must-die Quote Link to comment https://forums.phpfreaks.com/topic/266876-noob-in-need-of-help/#findComment-1368410 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.