Reputation: 1301
I have query which is not working
$lokesh = "select * from license_info where mac_id='$mac_id' and admin_user_name='$admin'";
In above query I am selecting record where macid and admin_user_name where matched
But while I echo this sql query it show output like
select * from license_info where mac_id='0800279020F2' and admin_user_name='sanjay
'
last single quotes is printing in below line so I am not able to retrive record. What is the reason of printing single quotes in below line
Upvotes: 3
Views: 64
Reputation: 1671
Remove the br
or new line feed tag
and execute it..
and use validation
$admin=htmlspecialchars($admin);
htmlspecialchars()
to avoid sql injection
or use htmlentities
$admin=htmlentities($admin);
Upvotes: 0
Reputation: 31153
The reason is that your variable $admin
contains a newline in the end. Remove it and there will be no problem with this.
You will, however, have a possible SQL injection attack. Use parameters, not inline values.
Upvotes: 4