Jump to content

[SOLVED]PHP unkown error.


SpeedCrazy

Recommended Posts

Hey guys,

I have an odd PHP problem,

<?php session_start(); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtm11/DTD/xhtml11-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>rollDie.php</title>
</head>
<body>
	<h1>Roll Dice</h1>
	<h2>Uses Functions</h2>
	<?php 
function init(){
global $count;
global $total;

if(isset($_SESSION["count"])){
	$count = $_SESSION["count"];
	$count++;
	$SESSION["count"] = $count;
} else {
	$_SESSION["count"]= 1;
	$_SESSION["total"]= 0;
	$count= 1;
} //end if
}//end init

function rollDie(){
global $total;

$roll = rand(1,6);
$image = "die$roll.jpg";
print<<< HERE
	<img src = "$image"
				alt = "roll: $roll" />

HERE;
$total = $_SESSION["total"];
$total+= $roll;
$_SESSION["total"]= $total;

} // end rollDie

init();
rollDie();

print "	<p>Rolls: $count</p> \n";
print " <p>Total: $total</p> \n";

	?>
</body>
</html>

With that code i get this.

 

Which is fine, except the 'Rolls:' stops at 2. I cant find any thing that deviates from my textbook but it may just be im tired.

Any help would be appreciated.

Thanks,

Speed

Edited by SpeedCrazy

Share this post


Link to post
Share on other sites

Upload it somewhere so I can test it out. I have a hunch.

 

I knew it was something with that line. But I didn't expect it to be a spelling mistake.

Edited by jjjrmy

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...