[PHP] Re: parse_str() expects parameter 1 to be string, array given

2009-10-19 Thread Al

Use var_dump() and see exactly what your variable is.

You can be certain it is really an array; the parser is good about such 
warnings.

Fix the source of the variable given to parse_str.

Julian Muscat Doublesin wrote:

Hello* *Everyone,

I am geetting the error below. Can you please guide me on a fix. It is
working on the live site but not on local server. Has anyone ever experinced
this error before.
*
Warning*: parse_str() expects parameter 1 to be string, array given**



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: parse_str()

2003-04-02 Thread Ron Rudman
I think you mean:

$example_string = '?action=kickitem=me';

Jose [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
I might be wrong here, but with the code below I would expect $_GET to be
filled and the script to output the next line:

   ?php
   $example_string = 'action=kickitem=me';
   parse_str($example_string);
   var_dump($_GET);
   ?

// expected output:
//
// array(2) { [action]=  string(4) kick [item]=  string(2) me }
//

Is my assumption wrong? What would be the workaround?

Thanks,

Jose







-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: parse_str()

2003-04-02 Thread Rasmus Lerdorf
 Jose [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 I might be wrong here, but with the code below I would expect $_GET to be
 filled and the script to output the next line:
 
?php
$example_string = 'action=kickitem=me';
parse_str($example_string);
var_dump($_GET);
?
 
 // expected output:
 //
 // array(2) { [action]=  string(4) kick [item]=  string(2) me }
 //
 
 Is my assumption wrong? What would be the workaround?

Your assumption is way wrong.  $_GET will only contain data that actually 
passed through a GET-method request.  Decoding a URL-encoded string 
doesn't suddenly make it GET data.  It will simply create entries in your 
global symbol table, or alternatively you can pass a second argument which 
is an array it will put the data into.  As per the docs.

-Rasmus


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php