|
Posted by DeanL on 05/10/07 00:06
On May 9, 4:55 pm, Iván Sánchez Ortega <ivansanchez-...@rroba-
escomposlinux.-.punto.-.org> wrote:
> 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.
Thank you all for your help. I'm currently reading the sections of
the PHP documentation. By the way, the book is O'Reillys "Learning
PHP & MySQL" which seems to have had its fair share of negative
comments by owners.
Once again, thanks and all the best, Dean...
[Back to original message]
|