Jump to content

Recommended Posts

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.