Jump to content

Archived

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

shocker-z

Case insensitive but sending Case sensitive??

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
nice try that i didnt think about but nope.. still the same :(

Any other idea's?

Share this post


Link to post
Share on other sites
This may help

http://dev.mysql.com/doc/refman/4.1/en/case-sensitivity.html

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
I says they are case-insensitive by default, so make sure you [b]haven't[/b] done any of those things that could make it case-sensitive

Share this post


Link to post
Share on other sites
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 :)

Share this post


Link to post
Share on other sites
My searches on the client column with that definition are case-insensitive.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Very strange symptoms... but you have it working now, yes?

Share this post


Link to post
Share on other sites

×

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.