Reputation: 31
I am unable to run this sql. This is not give me data.
$sql = "Select * from user where user_id=1'";
mysql_query($sql);
Upvotes: 2
Views: 100
Reputation: 522
Use this:
$sql = "Select * from user where user_id=1";
mysql_query($sql);
single quote after 1 is unnecessary.(also, the Numeric Data Types is not placed inside quotes for example.. '1' or "1" is incorrect and will throw an error,just in case this is what you were trying to do.)
Upvotes: 1
Reputation: 139
use this code
$sql = "Select * from user where user_id=1";
mysql_query($sql);
Upvotes: 1
Reputation: 313
Remove single quote (')
use this code:
$sql = "Select * from user where user_id=1";
mysql_query($sql);
Upvotes: 1
Reputation: 158
remove '
after 1, this is silly mistake.
$sql = "Select * from user where user_id=1";
mysql_query($sql);
Upvotes: 9
Reputation: 7103
There is an unncessary ' after 1
. But also:
http://php.net/manual/en/function.mysql-query.php
mysql_query() - this extension was deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0.
Better solution: MySQLi query
Upvotes: 1