Click to See Complete Forum and Search --> : case sensitive select


kproc
09-24-2006, 02:21 PM
Hi below is code that I use to select a row from a table. I'm trying to figure out how to make the select case sensitive


/// check to make sure update does not create duplicate value
$sql_parent_check = mysql_query("SELECT * FROM parent WHERE parentlastname = '$lastname' AND
parentfirstname = '$firstname' AND
parentdob = '$dob'")or die(mysql_error());

$parent_check = mysql_num_rows($sql_parent_check);


$row = mysql_fetch_assoc($sql_parent_check);

$Fparent_id = $row['parent_id'];

if(($parent_check == 1)){

$msg .= '<div style="width:325px" id= "formmessage">';
$msg .= "The change you made resulted in finding <b>".$firstname. ' '. $lastname. "</b> in the database, Click add family member to create link then click edit to delete the entry you where trying to edit<br />";
$msg .= '</div>';
include 'getfamily.php';
exit ();

kproc
09-24-2006, 02:25 PM
I forgot to mention, only the first letter will have a capital

NogDog
09-24-2006, 02:42 PM
It should already be case sensitive. Are you asking how to make it case insensitive, perhaps?

kproc
09-24-2006, 02:46 PM
the code that I posted is part of code that is used to update information in a table. the code is written so that douplicate enteries cannot be created. the problem that I'm having is if the select finds bill and the user is trying to change it to Bill it will not take the update because a match was found

NogDog
09-24-2006, 03:21 PM
My best guess is that your database, table, or column is using a case-insensitive collation type. If you view the database in phpMyAdmin, look for a Collation Type that ends in "_ci", indicating case-insensitive. If so, then your choices are to either change the collation to one that is case-sensitive ("_cs") or - perhaps better - rethink your logic concerning duplicate records.

kproc
09-26-2006, 07:03 PM
I solved my problem by changing my code like this


$sql_parent_check = mysql_query("SELECT * FROM parent WHERE parentlastname like binary '$lastname' AND
parentfirstname like binary '$firstname' AND
parentdob = '$dob'")or die(mysql_error());