Jump to content

screenshotcentral

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

screenshotcentral's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Sadly, that does not work either, it gives the exact same error on line 8, but I thank you for helping. I guess what I need to do is to learn more about sessions mixed with arrays in order to help work out these problems in the future. Do you know of anywhere where I can get information on session variables used as arrays? I have searched the net many times before coming here, but I could not find much of anything significant. The manual for php either has topics on sessions or ones on arrays, but never a mixture of the two. Thanks again. Exact code on the page: [code]<? session_start(); $ID=$_POST['ID']; $NAME=$_POST['NAME']; $PRICE=$_POST['PRICE']; if ( ! isset( $_SESSION['gun_array'] ) ) $_SESSION['gun_array'] = array( rand() ); $_SESSION['gun_array'] = array_push( $_SESSION['gun_array'] , $ID ); ?>[/code]
  2. When I used that script, the php gave an error saying [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Warning: array_push(): First argument should be an array (wesite path removed) on line 8[/quote] 7 if ( ! isset( $_SESSION['gun_array'] ) ) $_SESSION['gun_array'] = array(); 8 $_SESSION['gun_array'] = array_push( $_SESSION['gun_array'] , $id ); I understand that in order to push an array, an array must be stated inside of array_push(array, variable). When the script ran, I am guessing that it decided that $_SESSION_['gun_array'] was not a valid array to push. Also the code that previously worked to view the data was [code]<? session_start(); foreach($_SESSION['gun_array'] as $value) {echo("$value<BR>");} ?> [/code] but that does not seem to work now, which I assume is because the session variable fails to register as a legitmate array.
  3. I have a slight issue regarding session variables and arrays. [code]<? session_start(); $ID=$_POST['ID']; session_register('gun_array'); $_SESSION['gun_array']=$array; $array = array(); $array[]=$ID; [/code] This is what I have coded. I want start out with a blank array, then every time you access a certain page, a new $ID should be entered into the array. This value all depends on selections made on the previous pages. The problem I am having is that the new id just replaces the old id, and does not make an array. When I echo the array, its only give the one value, and is replaced when I change $ID. I read before that $array[]=(variable) is equivalent to array_push, but if it is, what else am I doing wrong, since array_push does not work either?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.