Jump to content

Case insensitive but sending Case sensitive??


shocker-z

Recommended Posts

Hi all,

Long time no POST (New job busy and all)

Just doing a small script for my work and i've come across a script that seems to be case sensitive, yet in my database the field is set as case insensitive??

Here is my code:

[code]<?php
$clientsearch=mysql_real_escape_string($_POST['clientname']);
$searchtype=mysql_real_escape_string($_POST['searchtype']);
if ($searchtype == 'start') {
$searchfor="$clientsearch%";
}
if ($searchtype == 'end') {
$searchfor="%$clientsearch";
}
if ($searchtype == 'any') {
$searchfor="%$clientsearch%";
}

$getclients=mysql_query("SELECT client, ID FROM clients WHERE client LIKE '$searchfor' ORDER BY client ASC");
while ($client=mysql_fetch_array($getclients)) {
echo "<option value=\"$client[ID]\" >$client[client]</option>";
}
?>[/code]

Any idea's?

Regards
Liam Wheldon
the problem may lie in the use of mysql_real_escape_string(); I however never use this function cause whenever i use this, the whole script does not work, mostly because the before mentioned function "real" escaped everything leaving nothing to return :D
hmm that seems to be all about making case sensitive searches not making something search case insensitive...

Might be missing somthing but i read the page 3 times...

Anything extra?


HMMM just tryed excecuting the code outside of PHP and i get the same results.. it's searching case sensitive!

any idea's on the mysql side?
here's my table if it helps??

CREATE TABLE `clients` (
  `ID` int(11) NOT NULL auto_increment,
  `client` varchar(35) default NULL,
  `abr` varchar(35) default NULL,
  `addr1` varchar(100) default NULL,
  `addr2` varchar(100) default NULL,
  `addr3` varchar(100) default NULL,
  `addr4` varchar(100) default NULL,
  `postcode` varchar(10) default NULL,
  PRIMARY KEY  (`ID`)
) ENGINE=MyISAM AUTO_INCREMENT=199 DEFAULT CHARSET=latin1;


Thanks for the help :)
Hmm.. all fields :S

tryed on another table and working now on them so will recreate table..

EDIT:

OK!!! I give up has someone spiked my Milkshake because after testing same code on another table and changing back it's now working!!! :D suppose that's a good thing ceopt i made no changes!!! :S


Thanks for the help :)


Liam

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.