Please login or register. Welcome to the Studio, guest!


Quick Links:


newBookmarkLockedFalling

Gunny

Gunny Avatar
Go Team Tux!

**
Official Member

37


November 2005
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<head>
<title>Dice Rolling Page</title>
</head>

<h1>Gunny's Dice Rolling Page</h1>

<?php

function GetRandomNumber($Min="0", $Max="255", $Random="3") {
unset ($ReturnedValue);

if ($Random=="3" ) {
srand((double)microtime()*intval(rand(1,1000000)));
$ReturnedValue=intval(rand($Min, $Max));
}
if ($Random=="2" ) {
#
# HotBits does not use min or max. Instead, it generates a Hex number (00-FF).
# We fake min/max with hotbits.
#
$fp_HotBits = fopen ("http://www.fourmilab.to/cgi-bin/uncgi/Hotbits?nbytes=1&fmt=hex", "r");
$HotBits_Text = fread ($fp_HotBits, 4096);
$HotBits_PickedNumber=substr($HotBits_Text, 463, 2);
fclose($fp_HotBits);
$ReturnedValue=intval(((hexdec($HotBits_PickedNumber)/255)*($Max-$Min))+$Min);
}

if ($Random=="1" ) {
$fp_RandomOrg = fopen ("http://www.random.org/cgi-bin/randnum?num=1&min="."$Min"."&max="."$Max"."&col=1", "r");
$RandomOrg_Text = fread ($fp_RandomOrg, 4096);
$ReturnedValue=$RandomOrg_Text;
fclose($fp_RandomOrg);
}
return $ReturnedValue;
}

?>
<p>Roll:</p>
<form name="input" method="post" action=" echo $_SERVER['SCRIPT_NAME']">
<p>
<input type="submit" name="D3" value="D3" />
<input type="submit" name="D6" value="D6" />
<input type="submit" name="2D6" value="2D6" />
<input type="submit" name="3D6" value="3D6" />
<input type="submit" name="D10" value="D10" />
<input type="submit" name="2D10" value="2D10" />
<input type="submit" name="D100" value="D100" />
<input type="submit" name="2D100" value="2D100" />
</p>
</form>

<?php

if (isset($_POST['D3'])) {

$D100=GetRandomNumber("1","3","1");

echo " Your D3 roll is $D3";
}


if (isset($_POST['D100'])) {

$D100=GetRandomNumber("1","100","1");

echo " Your D100 roll is $D100";
}


if (isset($_POST['D6'])) {

$D6=GetRandomNumber("1","6","1");

echo " Your D6 roll is $D6";
}


if (isset($_POST['2D6'])) {

$D6a=GetRandomNumber("1","6","1");

$D6b=GetRandomNumber("1","6","1");

$D62=$D6a + $D6b;

echo " Your 2D6 roll is $D6a and $D6b, which adds up to make $D62";
}


if (isset($_POST['3D6'])) {

$D6a=GetRandomNumber("1","6","1");

$D6b=GetRandomNumber("1","6","1");

$D6c=GetRandomNumber("1","6","1");

$D63=$D6a + $D6b+$D6c;

echo " Your 3D6 roll is $D6a, $D6b and $D6c, which adds up to make $D63";
}


if (isset($_POST['D10'])) {

$D10=GetRandomNumber("1","10","1");

echo " Your D10 roll is $D10";
}


if (isset($_POST['2D10'])) {

$D10a=GetRandomNumber("1","10","1");

$D10b=GetRandomNumber("1","10","1");

$D102=$D10a + $D10b;

echo " Your 2D6 roll is $D10a and $D10b, which adds up to make $D102";
}


if (isset($_POST['D100'])) {

$D100=GetRandomNumber("1","100","1");

echo " Your D100 roll is $D100";
}


if (isset($_POST['2D100'])) {

$D100a=GetRandomNumber("1","100","1");

$D100b=GetRandomNumber("1","100","1");

$D1002=$D100a + $D100b;

echo " Your 2D6 roll is $D100a and $D100b, which adds up to make $D1002";

?>



When I try to run this program, I get this error

Parse error: parse error in c:\program files\easyphp1-8\www\dice\diceroller.php on line 183 (the last line)

Help please?


Last Edit: Jun 4, 2006 3:24:19 GMT by Gunny

Chris

Chris Avatar

******
Head Coder

19,519


June 2005
You forgot the ending bracket } for the last if.

Gunny

Gunny Avatar
Go Team Tux!

**
Official Member

37


November 2005
Now nothing happens when I click on the buttons.


Last Edit: Jun 4, 2006 4:50:27 GMT by Gunny

Chris

Chris Avatar

******
Head Coder

19,519


June 2005
Well, I don't even know what the script does so I can't really help. :P Specially since some of the pages are hidden.

Gunny

Gunny Avatar
Go Team Tux!

**
Official Member

37


November 2005
It's a modification of this, designed to generate random dice rolls.

newBookmarkLockedFalling