$parts = $struct->parts;

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

    $parts = $struct->parts;

    Turning on error_reporting (E_ALL); was quite an eye opener as to
    how much "fixing" PHP will do for the sloppy coder.

    I fixed all of the errors except:
    Notice: Undefined property: parts in
    /ContactManageme nt/contact_mainpag e.php on line 120

    where the line in question is:
    $parts = $struct->parts;

    where $struct = = imap_fetchstruc ture($in, $mid);

    $struct is an object, parts is an array of objects

    what would the correct syntax of the statement be ?

    bill
  • petersprc

    #2
    Re: $parts = $struct->parts;

    If you var_dump($struc t) right before that line, what do you see? It's
    probably false or otherwise invalid. Maybe because it wasn't defined
    or the imap function had a problem.

    On Jun 13, 9:19 pm, bill <nob...@spamcop .netwrote:
    Turning on error_reporting (E_ALL); was quite an eye opener as to
    how much "fixing" PHP will do for the sloppy coder.
    >
    I fixed all of the errors except:
    Notice: Undefined property: parts in
    /ContactManageme nt/contact_mainpag e.php on line 120
    >
    where the line in question is:
    $parts = $struct->parts;
    >
    where $struct = = imap_fetchstruc ture($in, $mid);
    >
    $struct is an object, parts is an array of objects
    >
    what would the correct syntax of the statement be ?
    >
    bill

    Comment

    • bill

      #3
      Re: $parts = $struct-&gt;parts;

      >
      On Jun 13, 9:19 pm, bill <nob...@spamcop .netwrote:
      >Turning on error_reporting (E_ALL); was quite an eye opener as to
      >how much "fixing" PHP will do for the sloppy coder.
      >>
      >I fixed all of the errors except:
      >Notice: Undefined property: parts in
      >/ContactManageme nt/contact_mainpag e.php on line 120
      >>
      >where the line in question is:
      >$parts = $struct->parts;
      >>
      >where $struct = = imap_fetchstruc ture($in, $mid);
      >>
      >$struct is an object, parts is an array of objects
      >>
      >what would the correct syntax of the statement be ?
      >>
      >bill
      >
      >
      petersprc wrote:
      If you var_dump($struc t) right before that line, what do you
      see? It's
      probably false or otherwise invalid. Maybe because it wasn't
      defined
      or the imap function had a problem.
      here is the dump
      object(stdClass )(12) { ["type"]= int(0) ["encoding"]= int(0)
      ["ifsubtype"]= int(1) ["subtype"]= string(5) "PLAIN"
      ["ifdescript ion"]= int(0) ["ifid"]= int(0) ["lines"]=>
      int(2) ["bytes"]= int(27) ["ifdisposit ion"]= int(0)
      ["ifdparamet ers"]= int(0) ["ifparamete rs"]= int(1)
      ["parameters "]= array(2) { [0]= object(stdClass )(2) {
      ["attribute"]= string(7) "CHARSET" ["value"]= string(10)
      "ISO-8859-1" } [1]= object(stdClass )(2) { ["attribute"]=>
      string(6) "FORMAT" ["value"]= string(6) "flowed" } } }

      Comment

      • Captain Paralytic

        #4
        Re: $parts = $struct-&gt;parts;

        On 14 Jun, 11:14, bill <nob...@spamcop .netwrote:
        On Jun 13, 9:19 pm, bill <nob...@spamcop .netwrote:
        Turning on error_reporting (E_ALL); was quite an eye opener as to
        how much "fixing" PHP will do for the sloppy coder.
        >
        I fixed all of the errors except:
        Notice: Undefined property: parts in
        /ContactManageme nt/contact_mainpag e.php on line 120
        >
        where the line in question is:
        $parts = $struct->parts;
        >
        where $struct = = imap_fetchstruc ture($in, $mid);
        >
        $struct is an object, parts is an array of objects
        >
        what would the correct syntax of the statement be ?
        >
        bill
        >
        petersprc wrote:
        >
        If you var_dump($struc t) right before that line, what do you
        see? It's
        probably false or otherwise invalid. Maybe because it wasn't
        defined
        or the imap function had a problem.
        >
        here is the dump
        object(stdClass )(12) { ["type"]= int(0) ["encoding"]= int(0)
        ["ifsubtype"]= int(1) ["subtype"]= string(5) "PLAIN"
        ["ifdescript ion"]= int(0) ["ifid"]= int(0) ["lines"]=>
        int(2) ["bytes"]= int(27) ["ifdisposit ion"]= int(0)
        ["ifdparamet ers"]= int(0) ["ifparamete rs"]= int(1)
        ["parameters "]= array(2) { [0]= object(stdClass )(2) {
        ["attribute"]= string(7) "CHARSET" ["value"]= string(10)
        "ISO-8859-1" } [1]= object(stdClass )(2) { ["attribute"]=>
        string(6) "FORMAT" ["value"]= string(6) "flowed" } } }- Hide quoted text -
        >
        - Show quoted text -
        So there you have the answer, parts is not listed.

        Comment

        • Jeff North

          #5
          Re: $parts = $struct-&gt;parts;

          On Wed, 13 Jun 2007 21:19:05 -0400, in comp.lang.php bill
          <nobody@spamcop .net>
          <JO2dnb2lgosJCu 3bnZ2dnUVZ_qCmn Z2d@cablespeedm i.comwrote:
          >| Turning on error_reporting (E_ALL); was quite an eye opener as to
          >| how much "fixing" PHP will do for the sloppy coder.
          >|
          >| I fixed all of the errors except:
          >| Notice: Undefined property: parts in
          >| /ContactManageme nt/contact_mainpag e.php on line 120
          >|
          >| where the line in question is:
          >| $parts = $struct->parts;
          >|
          >| where $struct = = imap_fetchstruc ture($in, $mid);
          ^^^^^
          Is that a typo or actual code. If code it might be the source of the
          problem.
          >| $struct is an object, parts is an array of objects
          >|
          >| what would the correct syntax of the statement be ?
          >|
          >| bill
          ---------------------------------------------------------------
          jnorthau@yourpa ntsyahoo.com.au : Remove your pants to reply
          ---------------------------------------------------------------

          Comment

          • bill

            #6
            Re: $parts = $struct-&gt;parts;

            Captain Paralytic wrote:
            On 14 Jun, 11:14, bill <nob...@spamcop .netwrote:
            >>On Jun 13, 9:19 pm, bill <nob...@spamcop .netwrote:
            >>>Turning on error_reporting (E_ALL); was quite an eye opener as to
            >>>how much "fixing" PHP will do for the sloppy coder.
            >>>I fixed all of the errors except:
            >>>Notice: Undefined property: parts in
            >>>/ContactManageme nt/contact_mainpag e.php on line 120
            >>>where the line in question is:
            >>>$parts = $struct->parts;
            >>>where $struct = = imap_fetchstruc ture($in, $mid);
            >>>$struct is an object, parts is an array of objects
            >>>what would the correct syntax of the statement be ?
            >>>bill
            >petersprc wrote:
            >>
            > If you var_dump($struc t) right before that line, what do you
            >see? It's
            > probably false or otherwise invalid. Maybe because it wasn't
            >defined
            > or the imap function had a problem.
            >>
            >here is the dump
            >object(stdClas s)(12) { ["type"]= int(0) ["encoding"]= int(0)
            >["ifsubtype"]= int(1) ["subtype"]= string(5) "PLAIN"
            >["ifdescript ion"]= int(0) ["ifid"]= int(0) ["lines"]=>
            >int(2) ["bytes"]= int(27) ["ifdisposit ion"]= int(0)
            >["ifdparamet ers"]= int(0) ["ifparamete rs"]= int(1)
            >["parameters "]= array(2) { [0]= object(stdClass )(2) {
            >["attribute"]= string(7) "CHARSET" ["value"]= string(10)
            >"ISO-8859-1" } [1]= object(stdClass )(2) { ["attribute"]=>
            >string(6) "FORMAT" ["value"]= string(6) "flowed" } } }- Hide quoted text -
            >>
            >- Show quoted text -
            >
            So there you have the answer, parts is not listed.
            >
            Well, that was simple.
            in a 1 part message, parts is empty.
            Ok, I will ignore that error because in the next line I check to
            see if $parts is empty

            Can anyone suggest a way of writing this so that the Notice error
            would not pop up when parts does not exist - or is it worth it to
            write super clean code ?

            Here is the code segment:
            $struct = imap_fetchstruc ture($in, $mid);
            $parts = $struct->parts;
            $i = 0;
            if (!$parts) { /* Simple message, only 1 piece */
            $attachment = array(); /* No attachments */
            $content = imap_body($in,$ mid );
            }
            else { /* Complicated message, multiple parts */
            stuff-------
            }

            bill

            Comment

            • bill

              #7
              Re: $parts = $struct-&gt;parts;

              Jeff North wrote:
              On Wed, 13 Jun 2007 21:19:05 -0400, in comp.lang.php bill
              <nobody@spamcop .net>
              <JO2dnb2lgosJCu 3bnZ2dnUVZ_qCmn Z2d@cablespeedm i.comwrote:
              >
              >| Turning on error_reporting (E_ALL); was quite an eye opener as to
              >| how much "fixing" PHP will do for the sloppy coder.
              >|
              >| I fixed all of the errors except:
              >| Notice: Undefined property: parts in
              >| /ContactManageme nt/contact_mainpag e.php on line 120
              >|
              >| where the line in question is:
              >| $parts = $struct->parts;
              >|
              >| where $struct = = imap_fetchstruc ture($in, $mid);
              ^^^^^
              Is that a typo or actual code. If code it might be the source of the
              problem.
              >
              >| $struct is an object, parts is an array of objects
              >|
              >| what would the correct syntax of the statement be ?
              >|
              >| bill
              ---------------------------------------------------------------
              jnorthau@yourpa ntsyahoo.com.au : Remove your pants to reply
              ---------------------------------------------------------------
              typo

              Comment

              • Jerry Stuckle

                #8
                Re: $parts = $struct-&gt;parts;

                bill wrote:
                Captain Paralytic wrote:
                >On 14 Jun, 11:14, bill <nob...@spamcop .netwrote:
                >>>On Jun 13, 9:19 pm, bill <nob...@spamcop .netwrote:
                >>>>Turning on error_reporting (E_ALL); was quite an eye opener as to
                >>>>how much "fixing" PHP will do for the sloppy coder.
                >>>>I fixed all of the errors except:
                >>>>Notice: Undefined property: parts in
                >>>>/ContactManageme nt/contact_mainpag e.php on line 120
                >>>>where the line in question is:
                >>>>$parts = $struct->parts;
                >>>>where $struct = = imap_fetchstruc ture($in, $mid);
                >>>>$struct is an object, parts is an array of objects
                >>>>what would the correct syntax of the statement be ?
                >>>>bill
                >>petersprc wrote:
                >>>
                >> If you var_dump($struc t) right before that line, what do you
                >>see? It's
                >> probably false or otherwise invalid. Maybe because it wasn't
                >>defined
                >> or the imap function had a problem.
                >>>
                >>here is the dump
                >>object(stdCla ss)(12) { ["type"]= int(0) ["encoding"]= int(0)
                >>["ifsubtype"]= int(1) ["subtype"]= string(5) "PLAIN"
                >>["ifdescript ion"]= int(0) ["ifid"]= int(0) ["lines"]=>
                >>int(2) ["bytes"]= int(27) ["ifdisposit ion"]= int(0)
                >>["ifdparamet ers"]= int(0) ["ifparamete rs"]= int(1)
                >>["parameters "]= array(2) { [0]= object(stdClass )(2) {
                >>["attribute"]= string(7) "CHARSET" ["value"]= string(10)
                >>"ISO-8859-1" } [1]= object(stdClass )(2) { ["attribute"]=>
                >>string(6) "FORMAT" ["value"]= string(6) "flowed" } } }- Hide quoted
                >>text -
                >>>
                >>- Show quoted text -
                >>
                >So there you have the answer, parts is not listed.
                >>
                Well, that was simple.
                in a 1 part message, parts is empty.
                Ok, I will ignore that error because in the next line I check to see if
                $parts is empty
                >
                Can anyone suggest a way of writing this so that the Notice error would
                not pop up when parts does not exist - or is it worth it to write super
                clean code ?
                >
                Here is the code segment:
                $struct = imap_fetchstruc ture($in, $mid);
                $parts = $struct->parts;
                $i = 0;
                if (!$parts) { /* Simple message, only 1 piece */
                $attachment = array(); /* No attachments */
                $content = imap_body($in,$ mid );
                }
                else { /* Complicated message, multiple parts */
                stuff-------
                }
                >
                bill
                if (isset($struct->parts)) { ...

                And yes, it is worth it to write clean code.

                --
                =============== ===
                Remove the "x" from my email address
                Jerry Stuckle
                JDS Computer Training Corp.
                jstucklex@attgl obal.net
                =============== ===

                Comment

                • bill

                  #9
                  Re: $parts = $struct-&gt;parts;

                  Jerry Stuckle wrote:
                  bill wrote:
                  >Captain Paralytic wrote:
                  >>On 14 Jun, 11:14, bill <nob...@spamcop .netwrote:
                  >>>>On Jun 13, 9:19 pm, bill <nob...@spamcop .netwrote:
                  >>>>>Turning on error_reporting (E_ALL); was quite an eye opener as to
                  >>>>>how much "fixing" PHP will do for the sloppy coder.
                  >>>>>I fixed all of the errors except:
                  >>>>>Notice: Undefined property: parts in
                  >>>>>/ContactManageme nt/contact_mainpag e.php on line 120
                  >>>>>where the line in question is:
                  >>>>>$parts = $struct->parts;
                  >>>>>where $struct = = imap_fetchstruc ture($in, $mid);
                  >>>>>$struct is an object, parts is an array of objects
                  >>>>>what would the correct syntax of the statement be ?
                  >>>>>bill
                  >>>petersprc wrote:
                  >>>>
                  >>> If you var_dump($struc t) right before that line, what do you
                  >>>see? It's
                  >>> probably false or otherwise invalid. Maybe because it wasn't
                  >>>defined
                  >>> or the imap function had a problem.
                  >>>>
                  >>>here is the dump
                  >>>object(stdCl ass)(12) { ["type"]= int(0) ["encoding"]= int(0)
                  >>>["ifsubtype"]= int(1) ["subtype"]= string(5) "PLAIN"
                  >>>["ifdescript ion"]= int(0) ["ifid"]= int(0) ["lines"]=>
                  >>>int(2) ["bytes"]= int(27) ["ifdisposit ion"]= int(0)
                  >>>["ifdparamet ers"]= int(0) ["ifparamete rs"]= int(1)
                  >>>["parameters "]= array(2) { [0]= object(stdClass )(2) {
                  >>>["attribute"]= string(7) "CHARSET" ["value"]= string(10)
                  >>>"ISO-8859-1" } [1]= object(stdClass )(2) { ["attribute"]=>
                  >>>string(6) "FORMAT" ["value"]= string(6) "flowed" } } }- Hide
                  >>>quoted text -
                  >>>>
                  >>>- Show quoted text -
                  >>>
                  >>So there you have the answer, parts is not listed.
                  >>>
                  >Well, that was simple.
                  >in a 1 part message, parts is empty.
                  >Ok, I will ignore that error because in the next line I check to see
                  >if $parts is empty
                  >>
                  >Can anyone suggest a way of writing this so that the Notice error
                  >would not pop up when parts does not exist - or is it worth it to
                  >write super clean code ?
                  >>
                  >Here is the code segment:
                  > $struct = imap_fetchstruc ture($in, $mid);
                  > $parts = $struct->parts;
                  > $i = 0;
                  > if (!$parts) { /* Simple message, only 1 piece */
                  > $attachment = array(); /* No attachments */
                  > $content = imap_body($in,$ mid );
                  > }
                  > else { /* Complicated message, multiple parts */
                  > stuff-------
                  > }
                  >>
                  >bill
                  >
                  if (isset($struct->parts)) { ...
                  >
                  And yes, it is worth it to write clean code.
                  >
                  Thank you

                  bill

                  Comment

                  Working...