I am using this query
"SELECT * FROM items WHERE itemname LIKE '%$name%'"
Now if the variable value of $name="alex" then is gives correct information. But if I enter value $name="alex " along with spaces in it then it does not give the results and returns 0 rows.
if I enter $name="alex dude" then this is a valid name but $name="alex dude " this is not valid. I don't want to remove all whitespaces but at the end of the string only
I have written a function to clear out spaces at the end of name. This is the function.
$checker = substr($dataname, -1);
if($checker == " ")
$func_name = substr_replace($dataname, "", -1)
$dataname = $func_name;
This gives me error that is PHP Parse error: syntax error, unexpected 'function' (T_FUNCTION) in C:\inetpub\vhosts\httpdocs\compare.php on line 176.
I don't understand why recursively calling function giving me error.
Can you guys help out with this and if there is better solution or better sql query than I am using, please help me!