i was trying to make a custom search engine and secure it from sql injection, but there is a part in my code that its making a change in the user provided input that doesn’t let me use the mysql_fix_string function.
here I’ll get the User input
<?php
include "conn.php";
$search=$_GET['search']
then i save it like this :
$search='%'.$search.'%';
i used this "'.$search.'" statement in all of my queries :
switch ($radio){
case "author":
$sql_author = 'SELECT * FROM classics WHERE author LIKE "'.$search.'"';
$stm_good= $conn->query($sql_author);
break;
i'm not sure what dose '%'.$search.'%'; is doing to my input , but when i change my queries to just $search the whole search engine will not work .
and when i use this '%'.$search.'%'; i can’t secure my input from sql injections
with the mysql_fix_string function , when i do it doesn’t return any search results just a blank page
That’s why i think this '%'.$search.'%' code is the problem
so if you know any thing about what dose '%' do to my code please tell me i did a lot of research i couldn’t find something that explains it .
all guidance are appreciated