Jump to content


Photo

How do you sen an array to another script?


  • Please log in to reply
3 replies to this topic

#1 onemind

onemind
  • Members
  • PipPip
  • Member
  • 28 posts

Posted 21 July 2006 - 10:22 AM

Hi,

I have a header like so: header("Location: errors.php?err=$errors"); 

Where $errors is an array.

When i run this it goes to a site with this address: /errors.php?err=Array

How do i pass an array properly?

Thanks

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 21 July 2006 - 10:26 AM

serialize it:
$errors = serialize($errors);

then when you retrieve the errors unserialize, them:
$errors = unserialize($_GET['errors']);

However Id suggest you use a cookie/sessions instead rather then sending the errors through the url.

#3 boralyl

boralyl
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 21 July 2006 - 11:18 AM

Any pages you use $_SESSION start it off with session_start().  Then you can use variables across scripts.  So on script 1 you can store the array in say $_SESSION['errors'] = $errors;  Then on script 2 you can recall it simply by using the $_SESSION['errors'] variable.

#4 onemind

onemind
  • Members
  • PipPip
  • Member
  • 28 posts

Posted 21 July 2006 - 11:55 AM

Thanks guys,

That works great :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users