MajorMo Posted July 17, 2008 Share Posted July 17, 2008 Hi, I am fairly new to php and am following an ebook and trying to teach myself php. I am up to the array chapter and the book gives me this code for a part of a dice program (below): <html> <head> <title> persistence demo </title> </head> <body> <h1>Persistence Demo</h1> <form> <? //increment the counters $txtBoxCounter++; $hdnCounter++; print <<<HERE <input type = "text" name = "txtBoxCounter" value = "$txtBoxCounter"> <input type = "hidden" name = "hdnCounter" value = "$hdnCounter"> <h3>The hidden value is $hdnCounter</h3> <input type = "submit" value = "click to increment counters"> HERE; ?> </form> </body> </html> The example in the book has the program incrementing by one every time the submit button is pushed but on my computer nothing happens when I hit submit even when I have copy/pasted the code straight out of the e-book. I think it may be a problem with my installation but I don't know where to start (i am running the latest version of apache-windows with mysql and php5), any help would be greatly appreciated. Link to comment https://forums.phpfreaks.com/topic/115247-new-to-php-installation-problems/ Share on other sites More sharing options...
The Little Guy Posted July 17, 2008 Share Posted July 17, 2008 I would change THIS: $txtBoxCounter++; $hdnCounter++; TO THIS: $txtBoxCounter = $_GET['txtBoxCounter']+1; $hdnCounter = $_GET['hdnCounter']+1; Example: http://iarepc.tzfiles.com/test.php Link to comment https://forums.phpfreaks.com/topic/115247-new-to-php-installation-problems/#findComment-592520 Share on other sites More sharing options...
MajorMo Posted July 17, 2008 Author Share Posted July 17, 2008 ok i will try now Link to comment https://forums.phpfreaks.com/topic/115247-new-to-php-installation-problems/#findComment-592526 Share on other sites More sharing options...
trq Posted July 17, 2008 Share Posted July 17, 2008 Indeed, it would seem your ebook is well out of date. Link to comment https://forums.phpfreaks.com/topic/115247-new-to-php-installation-problems/#findComment-592527 Share on other sites More sharing options...
MajorMo Posted July 17, 2008 Author Share Posted July 17, 2008 Thank you so much it is all fine and working now. Maybe it's time for a new book huh? The funny thing is that it is written for php 5 which is the version i am using now. Link to comment https://forums.phpfreaks.com/topic/115247-new-to-php-installation-problems/#findComment-592528 Share on other sites More sharing options...
trq Posted July 17, 2008 Share Posted July 17, 2008 The funny thing is that it is written for php 5 which is the version i am using now. Then I would suggest that it isn't well written. Theres a link in my sig to hudzilla, thats a good book/wiki, but you can't read it offline. Link to comment https://forums.phpfreaks.com/topic/115247-new-to-php-installation-problems/#findComment-592530 Share on other sites More sharing options...
The Little Guy Posted July 17, 2008 Share Posted July 17, 2008 maybe the author has his php set up differently. It could be set up to automatically set GET values to variables, just like ActionScript does. Link to comment https://forums.phpfreaks.com/topic/115247-new-to-php-installation-problems/#findComment-592531 Share on other sites More sharing options...
discomatt Posted July 17, 2008 Share Posted July 17, 2008 maybe the author has his php set up differently. It could be set up to automatically set GET values to variables, just like ActionScript does. AKA Register_globals On. This is not recommended, as has been off by default for some time. Come PHP 6 the option will no longer even exist. Link to comment https://forums.phpfreaks.com/topic/115247-new-to-php-installation-problems/#findComment-592535 Share on other sites More sharing options...
trq Posted July 17, 2008 Share Posted July 17, 2008 This is not recommended, as has been off by default for some time. Six years in fact. Link to comment https://forums.phpfreaks.com/topic/115247-new-to-php-installation-problems/#findComment-592567 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.