Welcome to WebmasterWorld Guest from 54.227.5.198

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Simple text matching problem

Cant get md5 version of text to match

     

frances

12:27 pm on Jun 12, 2008 (gmt 0)

10+ Year Member



I am trying to get php to match text with an md5 hash of the text stored in a text file:

$test = (trim(md5("SPECIALCODE12")) == $code)?"yes":"no";

But I get a false result whatever I do - even if I copy and paste the value of $code into the first half of the comparison. Also, if I echo out the two sides of the comparison, they look identical.

I'm sure this must be something really silly, but I can't think what.

I'ld really appreciate any help.

dreamcatcher

12:46 pm on Jun 12, 2008 (gmt 0)

WebmasterWorld Senior Member dreamcatcher is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Hi frances,

Try removing 'trim' from the statement.

dc

frances

12:52 pm on Jun 12, 2008 (gmt 0)

10+ Year Member



Thanks but that doesn't work. I only put in trim to see if that might be the problem.

frances

1:06 pm on Jun 12, 2008 (gmt 0)

10+ Year Member



It does work with strcmp() - just in case anyone ever has similar problem. But I still dont understand why it wouldnt match before.

eelixduppy

3:11 pm on Jun 12, 2008 (gmt 0)

WebmasterWorld Senior Member eelixduppy is a WebmasterWorld Top Contributor of All Time 5+ Year Member



You'd have to match the type, too. So like the following:

$test = (trim(md5("SPECIALCODE12")) [b]===[/b] $code) ? "yes" : "no";

frances

4:12 pm on Jun 12, 2008 (gmt 0)

10+ Year Member



Again thanks. And it doesn't matter now but === didn't work either.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month