Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.
$contestant_query = "select * from `news` where `main_body` LIKE '%$_POST[search]%' order by `headline`";
$safe_search = mysql_real_escape_string($_POST['search']);
$contestant_query = "SELECT * FROM news WHERE main_body LIKE '%$safe_search%' ORDER BY headline";
$res = mysql_query($contestant_query) or die("FAIL: $contestant_query BECAUSE: " . mysql_error());
$num = mysql_num_rows($res);
var_dump($num);
These are things you should be doing with every query, every time. It's tempting to take shortcuts, and PHP is notorious for permitting sloppy programming, but in the interest of getting accurate results fastest, all of these basic steps play together in ways that set you on the right course.
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Join the community of 500,000 technology professionals and ask your questions.