|
Posted by Ivαn Sαnchez Ortega on 05/09/07 23:55
DeanL wrote:
> I'm a total newbie at php and need a little help solving an error that
> is being generated when using a script contained in one of the
> O'Reilly books.[...]
>
> Error:
>
> Notice: Undefined index: search in G:\Web\Webserver\Apache2\htdocs
> \simple.php on line 7
It's not an "error" - it's a "notice". If you read the PHP manual on error
handling, you'll discover that they're quite different things.
> $search = $_GET["search"];
Try replacing that with:
if (isset($_GET['search'])) $search = $_GET['search'];
else $search = NULL;
Or even with the more compact ternary-operator form:
$search = isset($_GET['search']) ? $_GET['search'] : NULL ;
That should do it for now. And, while you're on it, read the PHP manual on
setting/unsetting variables - keep in mind that an unset (non-existent)
variable is very different from a NULL variable.
--
----------------------------------
IvΓ‘n SΓ‘nchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-
La audacia es en los negocios lo primero, lo segundo y lo tercero.
Navigation:
[Reply to this message]
|