The code you posted isn't working because your ->execute() method failed because you are not binding any input parameter for the ? placeholder in the query. If you were checking for errors from the ->execute() method you would be getting - No data supplied for parameters in prepared statement
If you are going to write an advanced database function/class, you must have error checking logic in your code so that you don't attempt to use data that doesn't exist.
The ->prepare() method can fail due to sql syntax errors, the bind_parm code can fail with an error, the ->execute() method can fail with an error, and the bind_result code can fail with an error. You must check at each step if your code worked before trying to use the result from that step.
If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.
Last edited by CFMaBiSmAd; 05-27-2013 at 01:09 AM..