Jump to content


Photo

code to disregard captilization


  • Please log in to reply
3 replies to this topic

#1 elis

elis
  • Members
  • PipPipPip
  • Advanced Member
  • 149 posts

Posted 29 September 2006 - 11:36 PM

I have the following code:
if($userpenname==($_POST['recip']))
		{$output.="........."

Problem is the 'if' function is only being carried if the character cases match exactly, is there a method to get the function to disregard capitalization?

#2 Barand

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

Posted 29 September 2006 - 11:41 PM

use strtolower() or strtoupper() to covert both to same capitalization.

EDIT or use strcasecmp()
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

#3 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 29 September 2006 - 11:41 PM

Make them both the same type...

<?php
if (strtolower($userpanname) == strtolower($_POST['recip'])){
   // output here
}
?>

Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#4 elis

elis
  • Members
  • PipPipPip
  • Advanced Member
  • 149 posts

Posted 30 September 2006 - 12:16 AM

Ah, thank you. This worked out quite well.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users