I work with xampp. I performed MySQL connection:
$connection = mysql_connect($host , $user , $passw);
mysql_select_db($db, $connection);
I received output with echo command (by check the boolean returned values) that connection is established and the database $db is found.
But the simplest query like:
$query = mysql_query("SELECT * FROM 'users'");
returns false. How can I debug why?Thanks.
An obligatory update: as mysql ext is no more, here are answers for two remaining MySQL APIs which I written on my site based on the experience from answering 1000s questions on :
In short, for mysqi the following line have to be added before
mysqli_connect()
call:while for PDO the proper error mode have to be set, for example
As of the old mysql ext,
To get an error from
mysql_query()
you have to usemysql_error()
function.So always run all your queries this way, at least until you develop a more advanced query handler:
the problem with your current query is
'users'
part. Single quotes have to be used to delimit strings while for the identifiers you have to use backticks:In order to see these errors during development, add these lines at the top of your code to be sure you can see every error occurred
on the production server, however, the value on the first line should be changed from 1 to 0