Array Concatenation

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alan Little

    #1

    Array Concatenation

    Can anyone tell me what the difference is between these two statements?
    The $x one works, the $ExpiringSubs one tells me "Fatal error:
    Unsupported operand types". They look essentially the same to me. One
    thing just occurred to me, though. The $x example is running under
    v4.3.6; the other is v4.3.0. Would this make any difference?

    $x[1] = $x[1] + $z;

    $ExpiringSubs[$CustID] = $ExpiringSubs[$CustID] + $dbRec;

    =============== =============== =============== =============

    var_dump($x)
    array(1) {
    [1]=>
    array(3) {
    ["a"]=> string(1) "A"
    ["b"]=> string(1) "B"
    ["c"]=> string(1) "z"
    }
    }

    var_dump($z)
    array(2) {
    ["c"]=> string(1) "C"
    ["d"]=> string(1) "D"
    }

    var_dump($Expir ingSubs) [one element]
    array(132) {
    [113774]=>
    array(7) {
    ["CustID"]=> string(6) "113774"
    ["Renew"]=> string(10) "2004-04-06"
    ["Email"]=> string(19) "xxxxxxxx@xxxx. com"
    ["Offer"]=> string(2) "19"
    ["Response"]=> string(10) "SWW1B03A3A "
    ["DeliveryMo de"]=> string(1) "1"
    ["TermEnds"]=> string(10) "1081224000 "
    }

    var_dump($dbRec )
    array(13) {
    ["FirstName"]=> string(4) "XXXX"
    ["LastName"]=> string(4) "XXXX"
    ["UserName"]=> string(8) "XXXXX"
    ["Password"]=> string(8) "XXXXX"
    ["CardID"]=> string(5) "69010"
    ["CardNum"]=> string(76) "XXXXX"
    ["CardExp"]=> string(4) "0606"
    ["Address1"]=> string(20) "XXXX XXXX Lane"
    ["Address2"]=> string(0) ""
    ["City"]=> string(10) "XXXXX"
    ["State"]=> string(2) "IN"
    ["Postal"]=> string(5) "46077"
    ["Country"]=> string(2) "US"
    }

    --
    Alan Little
    Phorm PHP Form Processor

  • Alan Little

    #2
    Re: Array Concatenation

    Carved in mystic runes upon the very living rock, the last words of Alan
    Little of comp.lang.php make plain:
    [color=blue]
    > Can anyone tell me what the difference is between these two statements?
    > The $x one works, the $ExpiringSubs one tells me "Fatal error:
    > Unsupported operand types". They look essentially the same to me. One
    > thing just occurred to me, though. The $x example is running under
    > v4.3.6; the other is v4.3.0. Would this make any difference?[/color]

    As soon as I posted this (naturally), it occured to me to try the test
    script ($x) under v4.3.0 and see if I got the error. I didn't, so that's
    not the issue.

    --
    Alan Little
    Phorm PHP Form Processor

    Comment

    • Mark Kuiphuis

      #3
      Re: Array Concatenation

      I'm not quite sure but as can be found on many different sites, place
      the $index in between ' ' or " " inside the brackets...

      So $x['1'] = $x['1'] + $z;

      $ExpiringSubs['$CustID'] = $ExpiringSubs['$CustID'] + $dbRec;

      Mark...

      Alan Little wrote:
      [color=blue]
      > Carved in mystic runes upon the very living rock, the last words of Alan
      > Little of comp.lang.php make plain:
      >
      >[color=green]
      >>Can anyone tell me what the difference is between these two statements?
      >>The $x one works, the $ExpiringSubs one tells me "Fatal error:
      >>Unsupported operand types". They look essentially the same to me. One
      >>thing just occurred to me, though. The $x example is running under
      >>v4.3.6; the other is v4.3.0. Would this make any difference?[/color]
      >
      >
      > As soon as I posted this (naturally), it occured to me to try the test
      > script ($x) under v4.3.0 and see if I got the error. I didn't, so that's
      > not the issue.
      >[/color]

      Comment

      • Alan Little

        #4
        Re: Array Concatenation

        Carved in mystic runes upon the very living rock, the last words of Mark
        Kuiphuis of comp.lang.php make plain:
        [color=blue]
        > Alan Little wrote:
        >[color=green]
        >> Carved in mystic runes upon the very living rock, the last words of
        >> Alan Little of comp.lang.php make plain:
        >>
        >>[color=darkred]
        >>>Can anyone tell me what the difference is between these two
        >>>statements ? The $x one works, the $ExpiringSubs one tells me "Fatal
        >>>error: Unsupported operand types". They look essentially the same to
        >>>me. One thing just occurred to me, though. The $x example is running
        >>>under v4.3.6; the other is v4.3.0. Would this make any difference?[/color]
        >>
        >>
        >> As soon as I posted this (naturally), it occured to me to try the
        >> test script ($x) under v4.3.0 and see if I got the error. I didn't,
        >> so that's not the issue.[/color]
        >
        > I'm not quite sure but as can be found on many different sites, place
        > the $index in between ' ' or " " inside the brackets...
        >
        > So $x['1'] = $x['1'] + $z;
        >
        > $ExpiringSubs['$CustID'] = $ExpiringSubs['$CustID'] + $dbRec;[/color]

        Thanks for the reply, but that would make the key a literal string. That
        is, it would use dollar-sign-C-u-s-t-I-D as the key.

        --
        Alan Little
        Phorm PHP Form Processor

        Comment

        • Alan Little

          #5
          Re: Array Concatenation

          Carved in mystic runes upon the very living rock, the last words of Alan
          Little of comp.lang.php make plain:
          [color=blue]
          > Can anyone tell me what the difference is between these two statements?
          > The $x one works, the $ExpiringSubs one tells me "Fatal error:
          > Unsupported operand types".[/color]

          GAAAAAHHHHHHH! SPE! SPE! (Stupid Programmer Error)

          $CustID is being extracted from $dbRec, from which you will notice it is
          missing -- I hadn't included it in the SELECT clause of the query, thus
          it was null.

          Thanks for playing, contestants. We have some lovely parting gifts for
          you.

          --
          This life has been recorded before a live studio audience.
          Alan Little
          Phorm PHP Form Processor

          Comment

          • Pedro Graca

            #6
            Re: Array Concatenation

            Alan Little wrote:[color=blue]
            > Can anyone tell me what the difference is between these two statements?
            > The $x one works, the $ExpiringSubs one tells me "Fatal error:
            > Unsupported operand types". They look essentially the same to me. One
            > thing just occurred to me, though. The $x example is running under
            > v4.3.6; the other is v4.3.0. Would this make any difference?
            >
            > $x[1] = $x[1] + $z;[/color]

            What is in $x[1] now?
            Are you sure adding arrays gives the result you expect?

            var_dump($x[1] + $z)
            array(4) {
            ["a"]=> string(1) "A"
            ["b"]=> string(1) "B"
            ["c"]=> string(1) "z" <= from $x[1]
            ["d"]=> string(1) "D"
            }


            [color=blue]
            > $ExpiringSubs[$CustID] = $ExpiringSubs[$CustID] + $dbRec;[/color]

            You didn't tell us

            var_dump($CustI D);


            --
            USENET would be a better place if everybody read: : mail address :
            http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
            http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
            http://www.expita.com/nomime.html : to 10K bytes :

            Comment

            • Pedro Graca

              #7
              Re: Array Concatenation

              Alan Little wrote:[color=blue]
              > Carved in mystic runes upon the very living rock, the last words of Alan
              > Little of comp.lang.php make plain:
              >[color=green]
              >> Can anyone tell me what the difference is between these two statements?
              >> The $x one works, the $ExpiringSubs one tells me "Fatal error:
              >> Unsupported operand types".[/color]
              >
              > GAAAAAHHHHHHH! SPE! SPE! (Stupid Programmer Error)
              >
              > $CustID is being extracted from $dbRec, from which you will notice it is
              > missing -- I hadn't included it in the SELECT clause of the query, thus
              > it was null.
              >
              > Thanks for playing, contestants. We have some lovely parting gifts for
              > you.[/color]


              Ah! You beat me to it by 15 minutes :-)
              Glad you solved your problem.

              --
              USENET would be a better place if everybody read: : mail address :
              http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
              http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
              http://www.expita.com/nomime.html : to 10K bytes :

              Comment

              • Doug Hutcheson

                #8
                Re: Array Concatenation

                "Alan Little" <alan@n-o-s-p-a-m-phorm.com> wrote in message
                news:Xns94E6676 E381CDalanphorm com@216.196.97. 132...[color=blue]
                > Carved in mystic runes upon the very living rock, the last words of Alan
                > Little of comp.lang.php make plain:
                >[color=green]
                > > Can anyone tell me what the difference is between these two statements?
                > > The $x one works, the $ExpiringSubs one tells me "Fatal error:
                > > Unsupported operand types".[/color]
                >
                > GAAAAAHHHHHHH! SPE! SPE! (Stupid Programmer Error)
                >
                > $CustID is being extracted from $dbRec, from which you will notice it is
                > missing -- I hadn't included it in the SELECT clause of the query, thus
                > it was null.
                >
                > Thanks for playing, contestants. We have some lovely parting gifts for
                > you.
                >
                > --
                > This life has been recorded before a live studio audience.
                > Alan Little
                > Phorm PHP Form Processor
                > http://www.phorm.com/[/color]

                ROTFLMAO !
                I gotta use that line somewhere....!
                "8-)
                --
                Remove the blots from my address to reply


                Comment

                Working...