I need to compare two string case insensitive here is my code
if(strcasecmp($genderseek,\"both\")==0)
{
$gender2=\"$Ugender==\'MALE\'||$Ugender==\'FEMALE\'\";
You would need to use PHP strtolower() function to compare everything at lower case. This way, case sensitivity will be eliminated.
First of all, in the first branch, your code should use $gender2.=
instead of just $gender2=
Second, if this is building an SQL query, which it looks like, then you might want to use the SQL functions LOWER
or UPPER
to do the comparison with MALE and FEMALE, depending on your dataset
Third, again if this is SQL, "$genderseek==$Ugender"
should read "$Ugender==$genderseek"
since judging from your code, $Ugender
holds the column name for gender whereas $genderseek
is what the user is searching for?
Finally, you should really look into prepared statements. Your current code seems to be very vulnerable to SQL injections!