Hello, I have carefully checked your code. The issue might be occurred when you entered invalid param and database could not find correct result.
If you want, I can fix this bug just in a moment. If you can accept my More

Maybe the SQL is not right, I havn't seen the first key word in SQL syntax.
Which database are you using? MySQL? If MySQL, select the first column, using the following SQL:
SELECT column_name(s)
FROM table_name
WHEMore