Jump to content

swcarrel

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Everything posted by swcarrel

  1. Thanks, Lite, you are right. kenrbnsn suggested the abs() function, which did the trick! [!--quoteo(post=371110:date=May 3 2006, 06:14 PM:name=litebearer)--][div class=\'quotetop\']QUOTE(litebearer @ May 3 2006, 06:14 PM) [snapback]371110[/snapback][/div][div class=\'quotemain\'][!--quotec--] ok, perhaps I may misunderstand exactly what you are looking for. My understanding of signed and unsigned is as follows: I have an inkling that you are referring to positive whole numbers as opposed to positve numbers with decilmal/fractional values?? Lite... [/quote] Bingo, Ken. That's exactly what I needed. Thanks! Sam [!--quoteo(post=371264:date=May 4 2006, 08:26 AM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ May 4 2006, 08:26 AM) [snapback]371264[/snapback][/div][div class=\'quotemain\'][!--quotec--] You want to look at the [a href=\"http://www.php.net/abs\" target=\"_blank\"]abs()[/a] function. The function gets the absolute value of a number. Ken [/quote]
  2. I posted yesterday, and both litebearer and Crayon Violent helped out (thanks), but I still need more help if someone is willing. Lite's solution worked great if the number was negative, but sometimes it isn't. I think Crayon gave me the solution, but I'm too green to implement it. Here's the section of code which is relevant: $Date = date("Y-m-d H:i:s"); $Transaction = date("Ymd") . $phone . $name; $ConfirmationNumber=crc32($Transaction); I would like the ConfirmationNumber to always be unsigned. Thanks samindenver Just in case it helps, here is the entire code using Litebearer's solution, which is working fine except for this little problem: <?php { $where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/")); $message="photo: ".$photo." office: ".$office." state: ".$state." name: ".$name." title: ".$title." phone: ".$phone." ext: ".$ext." cellphone: ".$cellphone." email: ".$email." comments: ".$comments." "; mail("cardorder@venturepub.com","On-line Card Order",$message,"From: $email"); $Date = date("Y-m-d H:i:s"); $Transaction = date("Ymd") . $phone . $name; $ConfirmationNumber=crc32($Transaction); $x = (-1); // negative 1 $ConfirmationNumber = $ConfirmationNumber * $x; $link = mysql_connect("localhost","cardorder","wW7X1fhT"); mysql_select_db("buscards",$link); $query="insert into tbcards (date,office,photo,state,name,title,phone,ext,cellphone,email,comments,ConfirmID) values ('".$Date."','".$office."','".$photo."','".$state."','".$name."','".$title."','".$phone."','".$ext."','".$cellphone."','".$email."','".$comments."','".$ConfirmationNumber."')"; mysql_query($query); $newurl = "Refresh: 0; url=http://venturepub.com/thankyou.php?ConfirmID=".$ConfirmationNumber; header($newurl); } ?>
  3. [!--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]viola Lite... [/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]viola Lite... [/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...
  4. 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...
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.