Jump to content


Photo

Case insensitive but sending Case sensitive??


  • Please log in to reply
9 replies to this topic

#1 shocker-z

shocker-z
  • Members
  • PipPipPip
  • Advanced Member
  • 864 posts
  • LocationNottingham

Posted 29 October 2006 - 04:40 PM

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:

<?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>";
}
?>

Any idea's?

Regards
Liam Wheldon
www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge

#2 ignace

ignace
  • Moderators
  • Now mod flavored
  • 6,430 posts
  • LocationBelgium

Posted 29 October 2006 - 05:09 PM

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

#3 shocker-z

shocker-z
  • Members
  • PipPipPip
  • Advanced Member
  • 864 posts
  • LocationNottingham

Posted 29 October 2006 - 06:57 PM

nice try that i didnt think about but nope.. still the same :(

Any other idea's?
www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge

#4 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,020 posts

Posted 29 October 2006 - 07:30 PM

This may help

http://dev.mysql.com...ensitivity.html
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#5 shocker-z

shocker-z
  • Members
  • PipPipPip
  • Advanced Member
  • 864 posts
  • LocationNottingham

Posted 29 October 2006 - 07:45 PM

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?
www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge

#6 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,020 posts

Posted 29 October 2006 - 07:49 PM

I says they are case-insensitive by default, so make sure you haven't done any of those things that could make it case-sensitive
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#7 shocker-z

shocker-z
  • Members
  • PipPipPip
  • Advanced Member
  • 864 posts
  • LocationNottingham

Posted 29 October 2006 - 07:54 PM

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 :)
www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge

#8 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,020 posts

Posted 29 October 2006 - 08:05 PM

My searches on the client column with that definition are case-insensitive.
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#9 shocker-z

shocker-z
  • Members
  • PipPipPip
  • Advanced Member
  • 864 posts
  • LocationNottingham

Posted 29 October 2006 - 08:23 PM

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
www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge

#10 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 29 October 2006 - 09:18 PM

Very strange symptoms... but you have it working now, yes?
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users