PHP Code Question
Posted: Mon Mar 13, 2006 8:29 am
Ok well I am in midst of learning php. Mostly php in game programming.
The book I am using is: PHP Game Programming by Matt Rutledge
So I got into chapter1 which tells me to type up this code and it should keep track of how many times you have accessed the page. I keep getting errors and am just wondering if its my machine.
So if you could help me out by checking it and or offering advice that would be wonderful!
This is the page: Example01
Here is the code:
The actual page code is:
I keep getting an error on line 10 which is session_register('nCount');
The book I am using is: PHP Game Programming by Matt Rutledge
So I got into chapter1 which tells me to type up this code and it should keep track of how many times you have accessed the page. I keep getting errors and am just wondering if its my machine.
So if you could help me out by checking it and or offering advice that would be wonderful!
This is the page: Example01
Here is the code:
Code: Select all
<?php
if(!session_is_registered('nCount'))
{
session_register('nCount');
$nCount = 1;
}
else
{
$nCount++;
}
?>
echo'
<p>Hello, you have seen this page <?php echo $nCount; ?> times.</p>
<p>To continue, <a href="somepage.php?<?php echo strip_tags(SID)?>;">click here (sompage.php?<?php echo strip_tags(SID)?>)</A></p>Code: Select all
<!doctype html public "-//W3C//DTD HTML 4.0 //EN">
<html>
<head>
<title>Chapter 1 Example. Figure 1.2</title>
</head>
<body>
<?php
if(!session_is_registered('nCount'))
{
session_register('nCount');
$nCount = 1;
}
else
{
$nCount++;
}
?>
echo'
<p>Hello, you have seen this page <?php echo $nCount; ?> times.</p>
<p>To continue, <a href="somepage.php?<?php echo strip_tags(SID)?>;">click here (sompage.php?<?php echo strip_tags(SID)?>)</A></p>
</body>
</html>