Jump to content


Photo

Make number unsigned


  • Please log in to reply
3 replies to this topic

#1 swcarrel

swcarrel
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 03 May 2006 - 10:29 PM

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);

}

?>

#2 litebearer

litebearer
  • Members
  • PipPipPip
  • Advanced Member
  • 2,357 posts
  • Locationwhite lake michigan

Posted 04 May 2006 - 12:14 AM

ok, perhaps I may misunderstand exactly what you are looking for.

My understanding of signed and unsigned is as follows:

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]INT stands for integer. This is a normal sized number that can be signed or unsigned. A signed number can include negative numbers while an unsigned number includes only positive numbers. The maximum number, if signed, is &endash; 2147483648 to 2147483647. An unsigned number can max out at 4294967295.[/quote]

I have an inkling that you are referring to positive whole numbers as opposed to positve numbers with decilmal/fractional values??

Lite...

all the brothers were valiant!

[br][br]The truely intelligent people are not those who create the dots; rather they are they ones with the ability to connect the dots into a coherent picture

#3 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 04 May 2006 - 02:26 PM

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

#4 swcarrel

swcarrel
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 04 May 2006 - 04:14 PM

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) View Post[/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) View Post[/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]





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users