You are here: Re: Complete newbie looking for a little help « PHP Programming Language « IT news, forums, messages
Re: Complete newbie looking for a little help

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]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация