Hello all,
Just want to ask you how could I disable case sensitivity in php.
I am comparing 2 strings (letters and numbers) to add to database (mysql) only non existing strings.
code:
if ($_GET['polozka'] !== $row3['polozka']){
$insertSQL = "INSERT INTO sklad (polozka, druh_tovaru, dodavatel, kusy) VALUES ('$_GET[polozka]', '$_GET[druh_tovaru]', '$_GET[dodavatel]', '$_GET[kusy]')";
$Result1 = mysql_query($insertSQL, $SQL) or die(mysql_error()); }
How could I make it to test if statement without case sensitivity?....I am fresh beginner in php, so I am looking for help from more experienced people....Thanks in advance...
4 10976 Atli 5,058
Expert 4TB
Hi.
You can turn any string to lower case using the strtolower() function.
Doing that to both the test strings will make the test case-insensitive.
ye yuo're right..
but i just realized that what i need is to make select from database case insensitive.....
What i need is to avoid to have 2 same items in the database. So i want to make test before I write something to database if there is this item already or not(does not matter if with big or small letters)
my code for this looks like this:
$query3 = "SELECT * FROM sklad WHERE polozka='$_GET[polozka]'";
$Result3= mysql_query($query3,$SQL);
$row3 = mysql_fetch_array($Result3,$SQL);
if ($_GET['polozka']!==$row3['polozka']){
$insertSQL = "INSERT INTO sklad (polozka, druh_tovaru, dodavatel, kusy) VALUES ('$_GET[polozka]', '$_GET[druh_tovaru]', '$_GET[dodavatel]', '$_GET[kusy]')";
$Result1 = mysql_query($insertSQL, $SQL) or die(mysql_error());
}
How could I make this test case insensitive?Like I said I am fresh beginner, so I
realize that whole code for this could be done smarter ...Thanx in advance for your advice..
OK I solved it (I hope its I good solution...let me know if there could be any bug)
$query3 = "SELECT * FROM sklad WHERE polozka='$_GET[polozka]'";
$Result3= mysql_query($query3,$SQL);
$row3 = mysql_fetch_array($Result3,$SQL);
if ($row3==0){
$insertSQL = "INSERT INTO sklad (polozka, druh_tovaru, dodavatel, kusy) VALUES ('$_GET[polozka]', '$_GET[druh_tovaru]', '$_GET[dodavatel]', '$_GET[kusy]')";
$Result1 = mysql_query($insertSQL, $SQL) or die(mysql_error());
else {
?>
<!-- pop up warning-->
<script type="text/JavaScript">Message('Polozka <? echo $row3['polozka'] ?> already exist !');
document.location.href = "index.php";
</script>
Atli 5,058
Expert 4TB
Ok, If im reading this right, you need to avoid adding the same item twice into your database?
If so you can simply mark the column UNIQUE when you create the table (or alter it if you already have) and use the strtolower() function to de-capitalize all strings before you insert them.
Then MySQL wont allow you to add the same text into the column twice.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Elliot Temple |
last post by:
Hi I have two questions. Could someone explain to me why Python is
case sensitive? I find that annoying. Also, why aren't there
multiline comments? Would adding them cause a problem of some...
|
by: Neo-LISPer |
last post by:
Hey
Recently, I researched using C++ for game programming and here is what
I found:
C++ game developers spend a lot of their time debugging corrupted
memory. Few, if any, compilers offer...
|
by: Starwiz |
last post by:
I'm a VB.net programmer, and I'm about to start working
with two C++ programmers and teach them .net.
I've decided to use C# in teaching them, since it's
similar enough to VB.net that I can read...
|
by: Jason Tesser |
last post by:
I am converting data from Access into Postgres and ran into an issue
with case sensitivity. Can I write queries in Access that will be case
insensitive without rewriting the queries. So I would...
|
by: Christian Sell |
last post by:
Hello,
I am running into a problem with PGs case sensitivity with regard to column and
table names. I am using program components that require the object names
returned from database metadata...
|
by: gregory_may |
last post by:
Is there any options in VS 2005 to better handle case issues in C# (Similar
to VB.Net)?
|
by: Anita Potekkat |
last post by:
Hello,
I had a question regarding Case Sensitivity in 10g & 9i.
(1) Does Case Sensitivity in Oracle have to do with data only? Or does it also effect table & column names? For e.g. in a table...
|
by: sweetpotatop |
last post by:
Hi,
I believe my SQL server was configured as Case sensitivity. I have a
number of stored procedures which were moved from a non-Case
sensitivity SQL server. Because of the Case sensitivity, I...
|
by: Lucky |
last post by:
Hi guys,
I'm having problem with case sensitive collation of SQL Database. one
my client is having case sensitive database. While developing the Data
Layer i didn't consider this scenario.
the...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |