On Sun, March 11, 2007 6:00 pm, Richard Kurth wrote: > > > Richard Kurth wrote: >> >> >> -----Original Message----- >> From: Stut [mailto:stuttle@xxxxxxxxx] >> Sent: Sunday, March 11, 2007 2:53 PM >> To: Richard Kurth >> Cc: php-general@xxxxxxxxxxxxx >> Subject: Re: Using array_search I get error >> >> Richard Kurth wrote: >>> This array comes from $_REQUEST of all data submitted >>> >>> $array='Array ( [id] => 17 [takeaction] => saveCustomFields [notes] >>> => >>> -- Feb 4, 2007 @ 9:16 PM --fdsfdsfsdfdsfsfsfds -- Feb 4, 2007 @ >>> 9:21 >>> PM --fdfdsfsdffsd -- February 11, 2007, @ 9:31 PM -- This is a tes >>> -- >>> February 14, 2007, @ 10:10 PM -- jhafjhfa afjahfajfhda >>> kasjdaksdhADSKJL [firstname] => NANCY [lastname] => ADKINS >>> [phone2] >>> => >> [address1] => 25 ALWARD CT. >>> [address2] => [city] => MARTINSVILLE [State] => AK [other] => [zip] >>> => >>> 24112 [country] => US [date18] => 03-13-2007 [text19] => test1 >>> [text20] => [rating] => 0 [status] => Active )'; when I use >>> array_search to find date18 >>> >>> $key = array_search('date18', $array); // $key = 1; >>> >>> I get Wrong datatype for second argument How come the array is >>> wrong >>> datatype isn't a array an array or am I using this wrong >> >> $array is a string, and array_search is expecting an array, so it's > correct. >> Where did you get that "array"? >> >> -Stut >> >> This array comes from $_REQUEST of all data submitted from a form > > Yeah, you said that in your first post. What I meant was where did it > come > from? > > What you have there is the output from print_r($_REQUEST). How exactly > are > you getting that string? Why are you creating it as a literal array > rather > than using $_REQUEST directly? > > What you have there is the output from print_r($_REQUEST). How exactly > are > you getting that string? Why are you creating it as a literal array > rather > than using $_REQUEST directly? > > -Stut > > This is for saving data from custom fields created by the user I don't > know > what they are named so I can't use $_REQUEST[name] to pull them from > the > array. > I am submitting a form to a script that will search thru the array and > find > the fields that are in there date18 text19 text20 these are user > custom > fields that I do not know what they are named. I what to compare what > is in > the array with a database table and if they match then save the > information > in the array for that item to the database. I would hazard a guess that as you try to pass the data along from page to page, at some point you did something like: <input type="hidden" name="array" value="<?php print_r($array)?>" /> Don't do that. print_r is nice for humans to read, but totally useless for PHP to re-construct an array. You'll need to do more like this: <?php foreach($array as $k=>$v){ echo "<input type=\"hidden\" name=\"array[$k]\" value=\"$v\" />\n"; } ?> But if $v itself is an array (possibly) then you need to write this recursively... I think you might be better off *NOT* passing this data around in your form, but using sessions. http://php.net/session_start Or I could be totally wrong in my theory, too. :-) > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php