homepage Welcome to WebmasterWorld Guest from 54.226.173.169
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Simple text matching problem
Cant get md5 version of text to match
frances




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

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




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

Hi frances,

Try removing 'trim' from the statement.

dc

frances




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

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

frances




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

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

eelixduppy




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

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

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

frances




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

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved