Jump to content

[SOLVED] case sensitive


ngreenwood6

Recommended Posts

First let me explain what is happening. A user has input data into a database. I was trying to have this data pulled back up and have it

displayed. I have created a few rules. If the user doesnt put anything in, it asks them to. if it doesnt match anything tell them there are no results. the problem is that as i am testing this i put in a capital letter as the first letter and it wont find it. I have to search by using a capital. This is the part that tells it to match it (elseif ($get_lastname != $lastname)). Does anyone know how I can make it none case sensitive.

 

Here is my code:

 

<?php

 

//include variables

include ("variables.php");

 

//include the database variables

include ("db.php");

 

$mysql_connect = mysqli_connect($host,$db_username,$db_password,$db_name)

or die ("Could not connect to database");

 

//variable to send data to the database

$result = mysqli_query($mysql_connect,$getfrom_db)

or die ("Error: ".mysqli_error($cxn));

 

$row = mysqli_fetch_array($result);

$firstname = $row['firstname'];

$lastname = $row['lastname'];

$id = $row['id'];

 

if (!$get_lastname)

{

include ("index.php");

echo ("Please enter a last name!");

}

elseif ($get_lastname != $lastname)

{

echo ("There are no results, please enter a different last name!");

}

else

{

echo ("$firstname $lastname your user id is $id!");

}

?>

 

 

Thanks for all your help. Great community

Link to comment
https://forums.phpfreaks.com/topic/117565-solved-case-sensitive/
Share on other sites

I don't see where you're performing the actual query... but you can always do with with MySQL alone

 

SELECT `whatever` FROM `table` WHERE `name` LIKE 'a%'

 

Will search for names that start with an A or a

 

Check out more on the LIKE syntax here

http://dev.mysql.com/doc/refman/5.0/en/pattern-matching.html

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.