Having problems passing a parameter to a sql query if the parameter has spaces in it. The code is
$statement="select di_timestamp, di_item_value
from data_item
where
fk_fc_id=(select fc_id
from field_column
where
fc_description ilike :sensor
and
fk_mds_id=( select mds_id
from monitored_data_set
where fk_pa_id=(select pa_id
from pilot_ambient
where
pa_ambient_name ilike :room
and
fk_sp_id=(
select sp_id
from School_Pilot
where sp_description ilike :name
)
)
)
)";
$query = $databaseConn->prepare($statement);
$query->execute(array(':sensor'=>$sensor,':room'=>$room,':name' => '%'.$school.'%'));
However if sensor contains any spaces the query fails. How can I resolve this? I've tried putting quotes in the parameter, quotes in the query, but nothing works.