friedice Posted October 13, 2010 Share Posted October 13, 2010 hello im having abit of trouble with adding more stuff to my query $langSpoken = $_POST['langSpoken']; $Specialty = $_POST['Specialty']; $surname = $_POST['surname']; $gmapSql2 = "SELECT * FROM Doctor"; if($langSpoken !="All Languages") $gmapSql2 .= " WHERE LanguageSpoken ='{$langSpoken}' OR LanguageSpoken2 ='{$langSpoken}' OR LanguageSpoken3 ='{$langSpoken}'"; $gmapSql2 .= " OR LanguageSpoken4 ='{$langSpoken}' OR LanguageSpoken5 ='{$langSpoken}'"; if($Specialty !="All Specialty") $gmapSql2 .= " AND Qualifications ='{$Specialty}'"; if($surname !="") $gmapSql2 .= " AND Surname = ''{$surname}"; $gmapResult2 = $mdb2->query($gmapSql2); $rowsFound2 = $gmapResult2->numRows(); it gives me an error Call to undefined method MDB2_Error::numRows() in /home/k/kcabriti/.HTMLinfo/WebProjectsem2/SearchDoctor.php on line 243 if i take out the 2 lines of surname it works fine but when i try search the db when it equals the search surname term it gives a error also is the other of WHERE arguments important? anyone noe y? thanks Link to comment https://forums.phpfreaks.com/topic/215747-multiple-and-and-or-clauses/ Share on other sites More sharing options...
awjudd Posted October 14, 2010 Share Posted October 14, 2010 Your quotes for the surname are incorrect: From: $gmapSql2 .= " AND Surname = ''{$surname}"; To: $gmapSql2 .= " AND Surname = '{$surname}'"; I also noticed that the $langSpoken thing will also have a problem because your if statement is missing curly braces. i.e. From: if($langSpoken !="All Languages") $gmapSql2 .= " WHERE LanguageSpoken ='{$langSpoken}' OR LanguageSpoken2 ='{$langSpoken}' OR LanguageSpoken3 ='{$langSpoken}'"; $gmapSql2 .= " OR LanguageSpoken4 ='{$langSpoken}' OR LanguageSpoken5 ='{$langSpoken}'"; To: if($langSpoken !="All Languages") { $gmapSql2 .= " WHERE LanguageSpoken ='{$langSpoken}' OR LanguageSpoken2 ='{$langSpoken}' OR LanguageSpoken3 ='{$langSpoken}'"; $gmapSql2 .= " OR LanguageSpoken4 ='{$langSpoken}' OR LanguageSpoken5 ='{$langSpoken}'"; } This should make the query valid. ~judda Link to comment https://forums.phpfreaks.com/topic/215747-multiple-and-and-or-clauses/#findComment-1121995 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.