Jump to content

Make number unsigned


swcarrel

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

}

?>
Link to comment
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...
Link to comment
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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.