Jump to content

like operator problem


aeonfox

Recommended Posts

Hi

I'm trying to work why the following paramter doesnt work properly. it seems to be ignoring the 'and' part of the query

i am using a mysql 5.1.41  server

 

$stmt = $mysqli ->prepare("select CandidateVotes,CandidateTitle, CandidatefirstName ,CandidateLastName,CandidateID from Candidate where ( CandidateFirstName like ? and  CandidateLastName like ?) order by CandidateVotes DESC LIMIT 0,?");

  $stmt->bind_param('sss', $code1,$code2,$noVotes);

 

$code1="%".$searchFirstName."%";

$code2="%".$searchLastName."%";

$stmt->execute();

$stmt->bind_result($candidateVotes,$candidateTitle,$candidateFirstName,$candidateLastName,$candidateID);

Link to comment
https://forums.phpfreaks.com/topic/235348-like-operator-problem/
Share on other sites

What, exactly, do you mean by "it seems to be ignoring the 'and' part of the query". Is the query returning ALL records where the first name is a match regardless of whether the last name matches or not? OR, is it returning results where the first name matches or the last name matches?

 

However I suspect your problem is due to a type

$stmt = $mysqli ->prepare("select CandidateVotes,CandidateTitle, CandidatefirstName ,CandidateLastName,CandidateID from Candidate where ( CandidateFirstName like ? and  CandidateLastName like ?) order by CandidateVotes DESC LIMIT 0,?");

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.