swcarrel Posted May 2, 2006 Share Posted May 2, 2006 Generating a unique confirmation number for an order -- using$Transaction = date("Ymd") . $phone . $name;$ConfirmationNumber=crc32($Transaction);This generates a negative number. I want to insert an unsigned number into the MySQL database, and print it on a "thank you" page to the customer.Be gentle -- I'm a REAL newbie... Quote Link to comment Share on other sites More sharing options...
litebearer Posted May 2, 2006 Share Posted May 2, 2006 Hmmm, how about[code]$x = (-1); // negative 1$y = 123456; // another negative number$y = $y * $x;[/code]violaLite... Quote Link to comment Share on other sites More sharing options...
.josh Posted May 2, 2006 Share Posted May 2, 2006 [code]<?php/** * Function to compute the unsigned crc32 value. * PHP crc32 function returns int which is signed, so in order to get the correct crc32 value * we need to convert it to unsigned value. * * @param $str - String to compute the unsigned crc32 value. * @return $var - Unsinged inter value. */function computeUnsignedCRC32($str){ sscanf(crc32($str), "%u", $var); return $var;}?>[/code] Quote Link to comment Share on other sites More sharing options...
swcarrel Posted May 2, 2006 Author Share Posted May 2, 2006 [!--quoteo(post=370747:date=May 2 2006, 05:20 PM:name=litebearer)--][div class=\'quotetop\']QUOTE(litebearer @ May 2 2006, 05:20 PM) [snapback]370747[/snapback][/div][div class=\'quotemain\'][!--quotec--]Hmmm, how about[code]$x = (-1); // negative 1$y = 123456; // another negative number$y = $y * $x;[/code]violaLite...[/quote]Perfect! Works fine. Seems like there should be a harder, more complicated way, though[!--quoteo(post=370747:date=May 2 2006, 05:20 PM:name=litebearer)--][div class=\'quotetop\']QUOTE(litebearer @ May 2 2006, 05:20 PM) [snapback]370747[/snapback][/div][div class=\'quotemain\'][!--quotec--]Hmmm, how about[code]$x = (-1); // negative 1$y = 123456; // another negative number$y = $y * $x;[/code]violaLite...[/quote][!--quoteo(post=370753:date=May 2 2006, 05:45 PM:name=samindenver)--][div class=\'quotetop\']QUOTE(samindenver @ May 2 2006, 05:45 PM) [snapback]370753[/snapback][/div][div class=\'quotemain\'][!--quotec--]Perfect! Works fine. Seems like there should be a harder, more complicated way, though[/quote]Thanks, Lite![!--quoteo(post=370751:date=May 2 2006, 05:30 PM:name=Crayon Violent)--][div class=\'quotetop\']QUOTE(Crayon Violent @ May 2 2006, 05:30 PM) [snapback]370751[/snapback][/div][div class=\'quotemain\'][!--quotec--][code]<?php/** * Function to compute the unsigned crc32 value. * PHP crc32 function returns int which is signed, so in order to get the correct crc32 value * we need to convert it to unsigned value. * * @param $str - String to compute the unsigned crc32 value. * @return $var - Unsinged inter value. */function computeUnsignedCRC32($str){ sscanf(crc32($str), "%u", $var); return $var;}?>[/code][/quote]Thanks, Cray -- I'll play with this one, too, in case sometimes the value is positive... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.