MySQL Forums
Forum List  »  Newbie

Re: Not working in MYSQL5.1
Posted by: Rick James
Date: August 19, 2010 08:15PM

Turn the code around (after backticking range), from
$getrange = $_GET['rangesel'];
$getwood = $_GET['woodsel'];
$getroom = $_GET['roomsel'];

if ($getrange == 'All') {
$getrange = '%';
}
if ($getwood == 'All') {
$getwood = '%';
}
if ($getroom == 'All') {
$getroom = '%';
}
to something like
$getrange = $_GET['rangesel'];
$getwood = $_GET['woodsel'];
$getroom = $_GET['roomsel'];

$wheres = array();
if ($getrange != 'All') {
    $e = mysql_real_escape_string($getrange);
    $wheres[] = "`range` LIKE '$e'";
}
if ($getwood != 'All') {
    $e = mysql_real_escape_string($getwood );
    $wheres[] = "wood LIKE '$e'";
}
if ($getroom != 'All') {
    $e = mysql_real_escape_string($getroom );
    $wheres[] = "room LIKE '$e'";
}
$where = implode(' AND ', $wheres)

* The query will run a lot faster whenever the user says All.

* You are protected from quotes, etc being in the input.

Options: ReplyQuote


Subject
Written By
Posted
August 18, 2010 05:43AM
August 18, 2010 06:14AM
August 18, 2010 06:37AM
August 18, 2010 06:39AM
August 18, 2010 06:46AM
August 18, 2010 07:34AM
August 18, 2010 06:40AM
August 19, 2010 11:32AM
Re: Not working in MYSQL5.1
August 19, 2010 08:15PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.