Jump to content

Archived

This topic is now archived and is closed to further replies.

swcarrel

Make number unsigned

Recommended Posts

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

}

?>

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites

×

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.