Jump to content

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
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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