jeffery1493 Posted January 31, 2007 Share Posted January 31, 2007 Hi All,I wonder if this is possible to do. What I have is a PHP function that is being called with a bunch of arguments like this:submit_post($name, $address, $city, $state, $zip);What I want to do is put $name $address $city $state $zip all into one string:$user_info = "'" . $name . "','" . $address . "','" . $city . "','" $state . "','" . $zip . "'";I can then put $user_info into a $_SESSION variable, and pass it among many different web pages.When I get to the last page, I could then do this:submit_post ($user_info)and run the function on all the info that was entered many pages ago.Does this make sense???It doesn't work the way I did it (obviously..........) Thanks if anybody has done something like this before....JEFFERY1493 Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 31, 2007 Share Posted January 31, 2007 You may need two functions to do this, or to make the argument an array rather than a string and several strings.You have it accepting 5 arguments one place, then 1 another, you seem to want two different functions. Just make two different functions. Quote Link to comment Share on other sites More sharing options...
jeffery1493 Posted January 31, 2007 Author Share Posted January 31, 2007 I don't understand the two functions idea, but make an array.......I never thought of that!The thing is, the submit_post is a PHPBB function that submits posts (like the one used to power this forum). I don't want to mess with that.What I am doing is taking all the user info when they enter a post, and then setting it aside. Then you go through several web pages where you make a payment. If the payment succeeds, then I want to run submit_post with the info you entered a long time ago.Say you put all the info into an array........how would you refer to it in submit_post()? Quote Link to comment Share on other sites More sharing options...
jeffery1493 Posted January 31, 2007 Author Share Posted January 31, 2007 I'm thinking maybe:$user_data[0]="Name";$user_data[1]="Address";$user_data[2]="City";.....Then do submit_post($user_data):? ? ? :P Quote Link to comment Share on other sites More sharing options...
simcoweb Posted January 31, 2007 Share Posted January 31, 2007 Jesirose, i've been trying to PM you but not sure if the system is working or if you're getting them. Contact me, please. Quote Link to comment Share on other sites More sharing options...
chronister Posted January 31, 2007 Share Posted January 31, 2007 I prefer associative arrays myself, because I don't think in numbers.... So I would do it like so.$user_data=array("name"=>"$name", "address"=>"$address", "city"=>"$city")Then you can pass the $user_data array into the function and inside the function use a specific piece by associative array namesubmit_post($user_data)$user_data['name'];$user_data['address'];$user_data['city'];@simcoweb --- I would not PM Jesirose unless she has allowed you to do so, She got pissed at another person doing this tonight. Read the rules Quote Link to comment Share on other sites More sharing options...
jeffery1493 Posted January 31, 2007 Author Share Posted January 31, 2007 The problem is, I don't want to make changes to the function 'submit_post' because it is used all over the place, for posting (written by phpbb).I tried constructing an array the way I mentioned but it bombed. It seemed to work in some examples I read though............... Quote Link to comment Share on other sites More sharing options...
chronister Posted January 31, 2007 Share Posted January 31, 2007 create your array like this,[code]$user_data=array("name"=>"$name", "address"=>"$address", "city"=>"$city", "state=>"$state", "zip=>"$zip")[/code]pass the pieces of the array into the function like this.[code]submit_post($user_data['name'] , $user_data['address'], $user_data['city'] , $user_data['state'], $user_data['zip'])[/code]Essentially it is exactly the same as [code]submit_post($name, $address, $city, $state, $zip);[/code]except that your using array pieces instead of straight variables. Quote Link to comment Share on other sites More sharing options...
simcoweb Posted January 31, 2007 Share Posted January 31, 2007 Thanks for the heads up, Chronister. Jesirose and I have indeed exchanged PM's before. However, it's not appearing to go through to her. Not sure why. I'm 100% certain, though, that it wasn't something belligerent or against the rules :) We discussed some work. Quote Link to comment Share on other sites More sharing options...
jeffery1493 Posted January 31, 2007 Author Share Posted January 31, 2007 I think that's just what I needed. Thanks!!! ;D Quote Link to comment Share on other sites More sharing options...
neylitalo Posted January 31, 2007 Share Posted January 31, 2007 [quote author=simcoweb link=topic=124831.msg517838#msg517838 date=1170227540]that it wasn't something belligerent or against the rules[/quote]It's against the rules. Don't PM members with requests for help, for two reasons. One: Your problem has the same priority as every other problem. We'll help you if and when we want to. Two: Solutions determined via PM are useless to the community. Nobody can benefit from a solution that they can't see. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.