Try like this:
$select = "SELECT table_name as tbl, column_name as col
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = 'derokor' AND
(
DATA_TYPE LIKE '%char' OR
DATA_TYPE LIKE '%text' OR
DATA_TYPE LIKE '%blob'
)";
$result = mysqli_query($link,$select);
while( $row = mysqli_fetch_assoc($result) ) {
mysqli_query($link,"UPDATE $row[tbl] SET $row[col] = TRIM($row[col])");
}
In my query 'derokor' is the name of the database I was testing on, you would need to change this to your database name.