RE: [PHP-DB] Can't do anything with variables
| From: | Doug Thompson | Date: | Mon, 07 Apr 2003 03:15:38 +0000 |
| Subject: | RE: [PHP-DB] Can't do anything with variables | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-26878@lists.php.net to get a copy of this message | ||
Unlike Luke, I'm not familiar with this book. However, it's a pretty safe bet that it was
written prior to the first version of PHP that defaulted register_globals to OFF.
All of your variables for the second page will be found in the global array $_POST[] because the
method for the form on the first page is POST.
If you are developing on a private system, you can set register_globals ON in php.ini so that what
you are learning will follow the book. As soon as you get a bit more experience, turn the
register_globals back off and revise your scripts to work with the global arrays. The revision
needs to be nothing more than a series of statements near the beginning of a page to initialize the
local variables to the global array values. For example,
$searchtype = $_POST['searchtype'];
... etc. ...
Then the rest of your script(s) should work as written.
Enjoy,
Doug
--Original Message Text---
From: Luke Woollard
Date: Mon, 7 Apr 2003 11:34:01 +1000
Dude - sweet book. I bought it myself when i was starting out.
Your problem is due to the PHP error message setting in the php.ini file.
Whack this at the beginning of your scripts:
// Report simple running errors
error_reporting (E_ERROR | E_WARNING | E_PARSE);
When you know more - check out the php.ini file and read about the error
level..
And this page in the PHP manual:
http://www.php.net/manual/en/function.error-reporting.php
Cheers,
Luke Woollard
-----Original Message-----
From: Gilles [mailto:webmaster@bionix.net]
Sent: Monday, 7 April 2003 11:18 AM
To: php-db@lists.php.net
Subject: [PHP-DB] Can't do anything with variables
Hi all,
Sorry for this really beginner question (PHP-Newbie here). I bought the book
"PHP and MySQL web developpement" (Welling & Thompson) and I'm trying to
recreate the exemples and it won't work. I installed PHP 4.3.1 and MySQL
4.0.12.
The easy part. Here's a simple form page (from the book):
SEARCH.HTML
Book-O-Rama Catalog Search
Book-O-Rama Catalog Search
Choose Search Type:
Author Title ISBN
Enter Search Term:
And now the processing page:
RESULTS.PHP
Book-O-Rama Search Results
Book-O-Rama Search Results
Number of books found: ".$num_results.""; for ($i=0; $i ".($i+1).". Title:
"; echo stripslashes($row["title"]); echo "
Author: "; echo stripslashes($row["author"]); echo "
ISBN: "; echo stripslashes($row["isbn"]); echo "
Price: "; echo stripslashes($row["price"]); echo ""; } ?>
The problem. Even if I fill both fields, I always get "Notice: Undefined
variable: searchtype"
The only way it would work is if I remove all the "if" part and leave the
"select * from books" (without the where clause).
I don't get it. Any help would be much appreciated.
Regards
Gilles
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php