Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 11th, 2004, 10:08 PM
Registered User
 
Join Date: Mar 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Probably an old question

Since register_globals is now set to off by default, it seems that many of the code examples in the book will no longer work. As a result, going through this book now I have PHP up and running is a case of trying to find why the code won't work and correcting it. Granted, this is a great idea for training me to do proper bug fixing at a later date ... but it is occasionally frustrating ...

So ... has any helpful subscriber to this marvelous bulletin board made copies of the code files given the register_globals situation?

If so, you would make a frustrated PHP newbie a happy man ... if that's allowed LOL

:)

Old Irish Proverb:

Never take in eejit with you, you can always find one when you get there ...
 
Old March 12th, 2004, 12:53 AM
Registered User
 
Join Date: Mar 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to khairie Send a message via MSN to khairie Send a message via Yahoo to khairie
Default

What I did was to add $_GET or $_POST variable in the action script before I use the variable. For example, in Chapter 3 we learn about checkbox, and in checkbox.html we have :-
Code:
<form method="post" action="checkbox.php">
Have you ever eaten haggis before?
<input name="Choice" type="Checkbox">
<br>
<br>
<input type="Submit">
</form>
So, in the action script (that's checkbox.php), I used this code to have it displayed :-
Code:
<?php
$Choice = $_POST['Choice'];
echo "$Choice";
?>
Beware the $_POST variable. In this example, we used the form method post, therefore in the action script we used $_POST to catch the value of the variable. If we happens to use the form method get, the you should changed that to $_GET['Choice'].

Correct me if I'm wrong since I'm also a newbie in PHP. :D

Cheers.

Something to ponder...
:: People who know one (programming) language, or two, or even three, are NOT programmers. Programmers understand what programming is about and should be able to program in any language given them. ::
 
Old March 12th, 2004, 01:00 AM
Registered User
 
Join Date: Mar 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yeah ... I am working my way through doing that, but I am wasting valuable learning time having to rewrite code ... Fair enough, this gives some practical experience, but when we're talking about mostly very basic code it's not exactly taxing ... just frustrating ...

I guess I was wondering If anyone with more patience than me had already done it, so I could download it ...

Old Irish Proverb:

Never take in eejit with you, you can always find one when you get there ...
 
Old March 12th, 2004, 05:52 PM
Registered User
 
Join Date: Mar 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Anyone else got any idea of where I can find alternate code examples?

I kinda thought that, seeing as the recent change made the code in the book unhelpful to the learner, someone at WROX would have done it. But it appears not ...

Old Irish Proverb:

Never take in eejit with you, you can always find one when you get there ...
 
Old March 17th, 2004, 09:21 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I haven't heard of anyone rewriting the originals to work with register_globals = off, mainly because many of the examples are designed with register_globals = on in mind.

Programmers once thought it was elegant to take advantage of naming conflicts with variables, so they'd register session variables with the same names as form variables. When they used these variables later in the script, they didn't know or care where the value came from.

The result is that many scripts would become much uglier since the programmer would have to figure out where the value was really coming from.


You can use extract() to create global copies of variables in arrays.


Something like this should work (if you don't want to turn on register_globals):

$superglobals = array("GET", "POST", "SESSION", "ENV", "SERVER", "COOKIE");

foreach($superglobals as $var)
{
    $var_name = '$_' . $var;
    extract($$var_name);
}



Take care,

Nik
http://www.bigaction.org/
 
Old March 21st, 2004, 07:59 PM
Registered User
 
Join Date: Mar 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

PROBLEM: register_globals is now off by default, and WROX are selling a book with code that no longer works, unless a beginner become an expert overnight. This book cost me £29 ($55), and the code in it is OBSELETE as far as a beginners initial installation of PHP is concerned (unless the security of the machine is comprimised). Whilst I understand that the book can't be replaced for one with the right code in it, the least WROX could do is actually post the new code with some pointers for beginners.

FACT: This is bloody poor customer service, and to be quite frank I won't be buying any more books by WROX ... I expected just a quick run through on a new langauge (I already code in several). This is now turning into a major ball-ache, because every time something doesn't work I have to trawl the net for reasons why. This book should have taken a week or so to go through, but so far I am a month in and ready to set fire to the book.

TRUTH: Good old Caveat Emptor at work again I see ...

Old Irish Proverb:

Never take in eejit with you, you can always find one when you get there ...
 
Old March 21st, 2004, 08:45 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Quote:
quote:Originally posted by Aiken Drum

PROBLEM: register_globals is now on by default, and WROX are selling a book with code that no longer works, unless a beginner become an expert overnight. This book cost me £29 ($55), and the code in it is OBSELETE as far as a beginners initial installation of PHP is concerned (unless the security of the machine is comprimised). Whilst I understand that the book can't be replaced for one with the right code in it, the least WROX could do is actually post the new code with some pointers for beginners.

FACT: This is bloody poor customer service, and to be quite frank I won't be buying any more books by WROX ... I expected just a quick run through on a new langauge (I already code in several). This is now turning into a major ball-ache, because every time something doesn't work I have to trawl the net for reasons why. This book should have taken a week or so to go through, but so far I am a month in and ready to set fire to the book.

TRUTH: Good old Caveat Emptor at work again I see ...
1.) register_globals is set to off by default not on. While the Wrox book _is_ a bit dated and should be revised, the work arounds are easy -- given you are willing to do a bit of research.

2.) The security of the machine isn't as compromised as you might think, and while *learning* the language is irrelevant anyway IMHO -- worry about security in a production site not while you're trying to learn the language, as basic concepts become clearer security will also become clearer! Turn register_globals back on in php.ini and all will be well. Set error_reporting to
error_reporting = E_ALL & ~E_NOTICE
and the environment of the book's authors is recreated. I would suggest turning the settings on to see the examples work and then rewrite the code for register_globals = off and error_reporting = E_ALL. This will build problem solving skills and make you a better programmer. Many of the books examples *have* been rewritten for these settings in various posts to the p2p forums -- its just a matter of finding them -- you don't think you're the first person to ask a question on this topic, do you? I think the central reason that a new edition has yet to be released is these settings can be reset to their original defaults. Is it good practice? No, but again, learn the basic concepts first then learn how to write code to the more rigid standards. Should they release a new book, sure, I think so. PHP5 is still in beta, I'm sure the next book will be geared to PHP5.

3.) There is tons of information on the register_globals setting on php.net and the p2p forums. Simply search: http://www.google.com/search?q=regis...e:p2p.wrox.com

Or read the PHP manual:
http://www.php.net

4.) Whining to the subscribers of this list isn't going to do you any good, we are not Wrox/Wiley employees. Try the p2p and Wrox feedback forum.

I don't mean to rant, as I realize this is frustrating, but the solution to the problem isn't posting flame! In fact if you ask nicely and post the relevant code along with your question 9/10 times someone will help.

: )
Rich

:::::::::::::::::::::::::::::::::
Smiling Souls
http://www.smilingsouls.net
:::::::::::::::::::::::::::::::::





Similar Threads
Thread Thread Starter Forum Replies Last Post
question maheshraju ASP.NET 2.0 Basics 3 March 13th, 2008 08:54 AM
Question Ashwini Classic ASP Databases 3 January 10th, 2006 07:20 AM
Question? Calibus Classic ASP Databases 8 August 6th, 2004 08:25 AM
a question gorji C++ Programming 2 August 11th, 2003 07:41 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.