June 20, 200818 yr SOLVED I can't get this to work, i have a property site which searches dependant on 3 variable and it seems to be ignoring the variable (therefore not searching:() here is my code // set price range if ($price < 1) { $price = '["price=0 to 500000000000"]'; } elseif ($price == 1) { $price = '["price=0 to 50000"]'; } elseif ($price == 2) { $price = '["price=50000 to 100000"]'; } elseif ($price == 3) { $price = '["price=100000 to 150000"]'; } elseif ($price == 4) { $price = '["price=150000 to 200000"]'; } elseif ($price == 5) { $price = '["price=200000 to 250000"]'; } elseif ($price == 6) { $price = '["price=250000 to 350000"]'; } elseif ($price == 7) { $price = '["price=350000 to 400000"]'; } elseif ($price == { $price = '["price=400000 to 500000"]'; } elseif ($price == 9) { $price = ''; } // set property type range if ($property_type < 0) { $prop_type = ''; } elseif ($property_type == 1) { $prop_type = '[type/en="Apartment"]'; } elseif ($property_type == 2) { $prop_type = '[type/en="Duplex"]'; } elseif ($property_type == 3) { $prop_type = '[type/en="Town house"]'; } elseif ($property_type == 4) { $prop_type = '[type/en="Villa"]'; } elseif ($property_type == 5) { $prop_type = '[type/en="Cortijo"]'; } elseif ($property_type == 6) { $prop_type = '[type/en="Log home"]'; } elseif ($property_type == 7) { $prop_type = '[type/en="Finca"]'; } elseif ($property_type == { $prop_type = '[type/en="Bungalow"]'; } elseif ($property_type == 9) { $prop_type = '[type/en="Pentouse"]'; } elseif ($property_type == 10) { $prop_type = '[type/en="Cave house"]'; } // set berrom no range //if ($bedroom_no > 4){ // $bedroom_no = "[beds>4]"; if ($bedroom_no < 1){ $bedroom_no = "[beds>0]"; } else { $bedroom_no = "[beds=$bedroom_no]"; } // Include the pagination class include 'pagination.class.php'; // Create the pagination object $pagination = new pagination; // some example data // set xpath search $result = $xml->xpath("//property".$price.$prop_type.$bedroom_no.""); // initiate the search and display list foreach ( $result as $list) { $propertyid = $list->id ; $date = $list->date; $ref = $list->ref; $price = $list->price; i thought that the quotes around $price may be my problem but i can't get it working $price = '["price=0 to 50000"]'; instead of $price = '[price=0 to 50000]'; if i remove the quotes and add a single variable to $result, it works fine, but if i include other variable i get this error. Warning: SimpleXMLElement::xpath() [function.SimpleXMLElement-xpath]: Invalid predicate in C:\xampp\htdocs\test\search.php on line 84 Warning: SimpleXMLElement::xpath() [function.SimpleXMLElement-xpath]: xmlXPathEval: evaluation failed in C:\xampp\htdocs\test\search.php on line 84 Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\test\search.php on line 87 does anyone know where i may be going wrong?
June 25, 200818 yr Author managed to solve it by setting $price =[price>15000][price < 200000], etc ta
Create an account or sign in to comment