When I do
SELECT count(*) FROM table_name WHERE id= 2
The code works but when I write it like this:
$try= 2;
SELECT count(*) FROM table_name WHERE id= $try;
The code doesn't work anymore. Can someone please explain?
When I do
SELECT count(*) FROM table_name WHERE id= 2
The code works but when I write it like this:
$try= 2;
SELECT count(*) FROM table_name WHERE id= $try;
The code doesn't work anymore. Can someone please explain?
MySQL use
@
symbol for the variables.Read http://dev.mysql.com/doc/refman/5.0/en/user-variables.html for more information
Try this would work:
use this
First of all you have to "include" your parameter properly into string
Second, you have to pass it to mysqli object
Then you have to fetch result
Obviously you have to create new
mysqli
object properly, as explained into link that I've provided you.