Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

two condition after where clauses

Tags:

sql

mysql

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

like image 313
LOKESH Avatar asked Nov 27 '25 06:11

LOKESH


1 Answers

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.

like image 187
Sami Kuhmonen Avatar answered Nov 29 '25 19:11

Sami Kuhmonen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!