Hi there asahmed,
Welcome to the Forum!
Try this, a simple preg_replace:-
$mysearch = "one love";//doesn't matter how many spaces are there
$mysearch = preg_replace("/ {2,}/", " ", $mysearch);
//the output remains as just one space
echo $mysearch;
and into the sql:-
//the string
$mysearch = "One Love";
//strip out extra spaces
$mysearch = preg_replace("/ {2,}/", " ", $mysearch);
//put into the query
$SqlQuery = "SELECT `id`, `songs` FROM `pages` WHERE `title` = '".mysql_real_escape_string($mysearch)."' ";
//send query
$sendQuery = mysql_query($SqlQuery);
You don't need to back tick the column names but I do it just by force of habit, it's just handy to have if you encounter column names with spaces in or reserved words in mysql - backticks effectively escape this: [
dev.mysql.com ]
Anyway, that will do the trick ;)
[EDIT]: You may need to check to see if the values/strings stored in the DB have upper case letters in them, if they don't you may need to use strtolower around the mysql_real_escape_string() to avoid missing a match because of case sensitivity, just a thought though :) and conversely you could use ucwords to the same effect if the words in the DB are each uppercase, there are a few options open to you though...
Cheers,
MRb