Two conditions after conditions

I have a request that doesn't work

$lokesh = "select * from license_info where mac_id='$mac_id' and admin_user_name='$admin'";

      

In the previous request I select the entry where macid and admin_user_name where mapped

But while I repeat this sql query, it prints output like

select * from license_info where mac_id='0800279020F2' and admin_user_name='sanjay
'

      

the last single quotes are printed below the line, so I cannot extract the entry. What is the reason for printing single quotes in the line below

+3


source to share


2 answers


The reason is that your variable $admin

contains a newline at the end. Delete it and there will be no problem with it.



You do, however, have a possible SQL injection attack. Use parameters, not built-in values.

+4


source


Delete 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);

      

0


source







All Articles