I have a PHP file to compare strings from a MySQL table and from a URL parameter.
I have detected a problem, some of the MySQL strings have blank spaces at the beginning and/or at the end of the string, and I don't know how to manage it, then sometimes the query is empty because of the blank spaces.
In my case, the source string is part of a URL parameter, $id, and the string to be compared is the string value of the field titulo
$id = $_GET['id'];
$arr = array();
$rs = mysql_query("SELECT * FROM tbcoordenadas where titulo='$id'");
while ($obj = mysql_fetch_assoc($rs)){
$arr[] = $obj['procedencia'];
}
echo json_encode($arr);
I would appreciate any help to solve this issue.
EXPLANATION CONSIDERING THIS IS NOT A DUPLICATE QUESTION.
As you all may see, the question supposed to be duplicated is not considering in any answer what I am asking in my question. My question is not about removing white spaces from a string, it is about removing white spaces of a MySQL field value.