You are here: Re: $request problem « PHP Programming Language « IT news, forums, messages
Re: $request problem

Posted by Jerry Stuckle on 03/11/06 07:00

Norman Peelman wrote:
> "Jerry Stuckle" <jstucklex@attglobal.net> wrote in message
> news:15edndHF8fD3jpDZ4p2dnA@comcast.com...
>
>>Joe Blow wrote:
>>
>>>Can anybody see a problem with this? Am I being stupid?
>>>
>>>if (!isset($_REQUEST["input"]) || "" == $_REQUEST["input"])
>>> {
>>>throw new Exception("need query");
>>> }
>>> else
>>> {
>>> echo "<p>Search words: $_REQUEST[input]";
>>> }
>>>/*
>>>* split input into array of query words
>>>*/
>>> $queries = array_map(mysql_real_escape_string, explode(" ",
>>>$_REQUEST["input"]));
>>>
>>>
>>>This works on one server, running PHP5, but not another. Both apache.
>>>I've checked php.ini but cannot see why this seemingly simple bit of
>>>code should fail in one instance.
>>>
>>>In the one where it fails to work $queries is set to "" where I would
>>>expect it to be set to an array of the values of $_REQUEST["input"],
>>>split at each space.
>>>
>>>No errors are reported even with error_reporting(E_ALL);
>>>
>>>$_REQUEST is definitely set as the echo line prints out the input as
>>>expected.
>>>
>>
>>Maybe your problem is:
>>
>> echo "<p>Search words: $_REQUEST['input']";
>> ^ ^
>>
>>P.S. I prefer to use single quotes around constants like this.
>>
>
>
> No,
>
> echo "<p>Search words: $_REQUEST[input]";
>
> is (one of) the correct ways. Single quotes aren't needed/don't work when
> the variable is enclosed in double quotes. Unless you enclose the variable
> in curly braces:
>
> echo "<p>Search words: {$_REQUEST['input']}";
>
> will work properly too...
>
> Norm
>
>

Yes, if you turn on all errors you will get an E_NOTICE because the
string is not quoted.


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

 

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

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация