Function inop, but tosses no errors

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

    Function inop, but tosses no errors

    HI,

    Below is fully functional, non-functional code :^): In other words, it
    works, but it doesn't do anything and darned if I can see why. None of
    the 3 $email assignments result in any output. I just kept two
    commented out so I could easily switch addresses for testing, thus the
    "#"s. It does not kick out any errors and syntax checks valid with
    tswebeditor (freebie).

    I've sprinkled some echoes here and there to try to see what's running
    but no help. I've indicated the ones that DO echo properly for me with
    <-------.
    I've checked syntax and pairing of brackets etc. in two differend
    IDEs and all looks OK.
    But, I've obviously pulled something stupid somwehere. It's pretty
    simple code and I think it's evident what's going on so I haven't yet
    added many comments. Basically, check the length left and right, how
    many DOTs and @, and no dots where they shouldn't be.
    But none of the if's result in any output & don't seem to be getting
    run, indicating something pretty obvious I'm sure, just not obvious to
    me!

    Any Help?

    Twayne


    ---------------------
    <?php
    $email="mine@do main.com";
    #$email="a@b.c" ;
    #$email=".mine. @.domain..com";
    echo "<br/>KB PFSTART"; <------- PFSTART etc are just ts names,
    nothing more.
    echo '<br/>using: ' . $email; <------- shows email address correctly


    function validateEmail($ email){
    $output = "Might be valid.";
    $email = trim($email);

    If ((strlen($email )<5) || strstr($email," "))
    {
    $output = "too short, " . strlen($email) . " characters.";
    echo "<br/>KB PF7";
    }
    If (substr_count($ email, "@")<>1)
    {
    $output = "<one @.";
    echo "<br/>KB PF6";
    }
    Else
    {
    If (strlen($halves[0])<1 || strlen($halves[1])<=3)
    {
    $output = "too few characters.";
    echo "<br/>KB PF5";
    }
    echo "<br/>KB PF3";
    If (substr($halves[0],0,1)=="." || substr($halves[0],-1,1)==".")
    {
    $output = " dot just before teh @.";
    echo "<br/>KB PF5";
    }
    If (substr($halves[1],0,1)=="." || substr($halves[1],-1,1)==".")
    {
    $output = " dot on end of tld";
    echo "<br/>KB PF5";
    }
    if (!strstr($halve s[1],".") || strstr($halves[1],".."))
    {
    $output = " wrong number of dots in it.";
    echo "<br/>KB PF5";
    }
    echo "<br/>KB PF7";
    }
    return $output;
    }
    echo '<br/>$output is ' . $output; # <--- $OUTPUT DOES NOT ECHO
    echo "<br/>KB PFEND"; <-------
    ?>
    --------- end ------------------




  • Twayne

    #2
    PS Re: Function inop, but tosses no errors

    PS Target: PHP 5.2.2 on remote server, using 5.2.5 locally on winXP Pro.
    Sorry for the omission.
    HI,
    >
    Below is fully functional, non-functional code :^): In other words,
    it works, but it doesn't do anything and darned if I can see why. None
    of the 3 $email assignments result in any output. I just kept
    two commented out so I could easily switch addresses for testing,
    thus the "#"s. It does not kick out any errors and syntax checks
    valid with tswebeditor (freebie).
    >
    I've sprinkled some echoes here and there to try to see what's running
    but no help. I've indicated the ones that DO echo properly for me
    with <-------.
    I've checked syntax and pairing of brackets etc. in two differend
    IDEs and all looks OK.
    But, I've obviously pulled something stupid somwehere. It's pretty
    simple code and I think it's evident what's going on so I haven't yet
    added many comments. Basically, check the length left and right, how
    many DOTs and @, and no dots where they shouldn't be.
    But none of the if's result in any output & don't seem to be getting
    run, indicating something pretty obvious I'm sure, just not obvious to
    me!
    >
    Any Help?
    >
    Twayne
    >
    >
    ---------------------
    <?php
    $email="mine@do main.com";
    #$email="a@b.c" ;
    #$email=".mine. @.domain..com";
    echo "<br/>KB PFSTART"; <------- PFSTART etc are just ts names,
    nothing more.
    echo '<br/>using: ' . $email; <------- shows email address correctly
    >
    >
    function validateEmail($ email){
    $output = "Might be valid.";
    $email = trim($email);
    >
    If ((strlen($email )<5) || strstr($email," "))
    {
    $output = "too short, " . strlen($email) . " characters.";
    echo "<br/>KB PF7";
    }
    If (substr_count($ email, "@")<>1)
    {
    $output = "<one @.";
    echo "<br/>KB PF6";
    }
    Else
    {
    If (strlen($halves[0])<1 || strlen($halves[1])<=3)
    {
    $output = "too few characters.";
    echo "<br/>KB PF5";
    }
    echo "<br/>KB PF3";
    If (substr($halves[0],0,1)=="." || substr($halves[0],-1,1)==".")
    {
    $output = " dot just before teh @.";
    echo "<br/>KB PF5";
    }
    If (substr($halves[1],0,1)=="." || substr($halves[1],-1,1)==".")
    {
    $output = " dot on end of tld";
    echo "<br/>KB PF5";
    }
    if (!strstr($halve s[1],".") || strstr($halves[1],".."))
    {
    $output = " wrong number of dots in it.";
    echo "<br/>KB PF5";
    }
    echo "<br/>KB PF7";
    }
    return $output;
    }
    echo '<br/>$output is ' . $output; # <--- $OUTPUT DOES NOT ECHO
    echo "<br/>KB PFEND"; <-------
    >>
    --------- end ------------------


    Comment

    • Michael Fesser

      #3
      Re: Function inop, but tosses no errors

      ..oO(Twayne)
      >Below is fully functional, non-functional code :^): In other words, it
      >works, but it doesn't do anything and darned if I can see why. None of
      >the 3 $email assignments result in any output. I just kept two
      >commented out so I could easily switch addresses for testing, thus the
      >"#"s. It does not kick out any errors and syntax checks valid with
      >tswebeditor (freebie).
      >
      >[...]
      >
      >
      >---------------------
      ><?php
      >$email="mine@d omain.com";
      >#$email="a@b.c ";
      >#$email=".mine .@.domain..com" ;
      >echo "<br/>KB PFSTART"; <------- PFSTART etc are just ts names,
      >nothing more.
      >echo '<br/>using: ' . $email; <------- shows email address correctly
      >
      >
      >function validateEmail($ email){
      >[...]
      >}
      Maybe a stupid question, but do you actually call this function
      somewhere?
      >echo '<br/>$output is ' . $output; # <--- $OUTPUT DOES NOT ECHO
      This line should cause an E_NOTICE error, since $output is not defined
      anywhere.

      Micha

      Comment

      • Twayne

        #4
        Re: Function inop, but tosses no errors

        .oO(Twayne)
        >
        >Below is fully functional, non-functional code :^): In other words,
        >it works, but it doesn't do anything and darned if I can see why.
        >None of the 3 $email assignments result in any output. I just kept
        >two commented out so I could easily switch addresses for testing,
        >thus the "#"s. It does not kick out any errors and syntax checks
        >valid with tswebeditor (freebie).
        >>
        >[...]
        >>
        >>
        >---------------------
        ><?php
        >$email="mine@d omain.com";
        >#$email="a@b.c ";
        >#$email=".mine .@.domain..com" ;
        >echo "<br/>KB PFSTART"; <------- PFSTART etc are just ts names,
        >nothing more.
        >echo '<br/>using: ' . $email; <------- shows email address correctly
        >>
        >>
        >function validateEmail($ email){
        >[...]
        >}
        >
        Maybe a stupid question, but do you actually call this function
        somewhere?
        Aww, darn it, yes; I forgot to inlcude the code. It's just a
        validateEmail($ email) statement after the "--...---" at the bottom of my
        posted code.
        >
        >echo '<br/>$output is ' . $output; # <--- $OUTPUT DOES NOT ECHO
        >
        This line should cause an E_NOTICE error, since $output is not defined
        anywhere.
        Nope; and I do have errors turned on, including notices, in .ini.

        $output is assigned multiple times as the function runs. e.g.
        $output = "Might be valid."; and
        $output = "too short, " . strlen($email) . " characters.";
        .... etc.
        Or did you mean something else I'm not catching on to?
        Each if(...){...} has a " $output = "...


        I thought possibly $email wasn't getting picked up or it was a scope
        problem, but I don't see anything. Time for me to sleep on it again, I
        think.

        Thanks, Micha

        Twayne


        Comment

        • Twayne

          #5
          Resolved Re: Function inop, but tosses no errors

          Did a Restart; now it's working! Damn! I already tried that once;
          guess I didn't hold my mouth right. Ya gotta love windows!



          HI,
          >
          Below is fully functional, non-functional code :^): In other words,
          it works, but it doesn't do anything and darned if I can see why. None
          of the 3 $email assignments result in any output. I just kept
          two commented out so I could easily switch addresses for testing,
          thus the "#"s. It does not kick out any errors and syntax checks
          valid with tswebeditor (freebie).
          >
          I've sprinkled some echoes here and there to try to see what's running
          but no help. I've indicated the ones that DO echo properly for me
          with <-------.
          I've checked syntax and pairing of brackets etc. in two differend
          IDEs and all looks OK.
          But, I've obviously pulled something stupid somwehere. It's pretty
          simple code and I think it's evident what's going on so I haven't yet
          added many comments. Basically, check the length left and right, how
          many DOTs and @, and no dots where they shouldn't be.
          But none of the if's result in any output & don't seem to be getting
          run, indicating something pretty obvious I'm sure, just not obvious to
          me!
          >
          Any Help?
          >
          Twayne
          >
          >
          ---------------------
          <?php
          $email="mine@do main.com";
          #$email="a@b.c" ;
          #$email=".mine. @.domain..com";
          echo "<br/>KB PFSTART"; <------- PFSTART etc are just ts names,
          nothing more.
          echo '<br/>using: ' . $email; <------- shows email address correctly
          >
          >
          function validateEmail($ email){
          $output = "Might be valid.";
          $email = trim($email);
          >
          If ((strlen($email )<5) || strstr($email," "))
          {
          $output = "too short, " . strlen($email) . " characters.";
          echo "<br/>KB PF7";
          }
          If (substr_count($ email, "@")<>1)
          {
          $output = "<one @.";
          echo "<br/>KB PF6";
          }
          Else
          {
          If (strlen($halves[0])<1 || strlen($halves[1])<=3)
          {
          $output = "too few characters.";
          echo "<br/>KB PF5";
          }
          echo "<br/>KB PF3";
          If (substr($halves[0],0,1)=="." || substr($halves[0],-1,1)==".")
          {
          $output = " dot just before teh @.";
          echo "<br/>KB PF5";
          }
          If (substr($halves[1],0,1)=="." || substr($halves[1],-1,1)==".")
          {
          $output = " dot on end of tld";
          echo "<br/>KB PF5";
          }
          if (!strstr($halve s[1],".") || strstr($halves[1],".."))
          {
          $output = " wrong number of dots in it.";
          echo "<br/>KB PF5";
          }
          echo "<br/>KB PF7";
          }
          return $output;
          }
          echo '<br/>$output is ' . $output; # <--- $OUTPUT DOES NOT ECHO
          echo "<br/>KB PFEND"; <-------
          >>
          --------- end ------------------


          Comment

          • Twayne

            #6
            PS Resolved Re: Function inop, but tosses no errors

            Just for clarity: The function functions; I didn't mean it has no other
            problems<g>. Just in case a newbie decides to try it out; didn't want
            to leave a false impression.

            Twayne
            Did a Restart; now it's working! Damn! I already tried that once;
            guess I didn't hold my mouth right. Ya gotta love windows!
            >
            >
            >
            >
            >HI,
            >>
            >Below is fully functional, non-functional code :^): In other words,
            >it works, but it doesn't do anything and darned if I can see why.
            >None of the 3 $email assignments result in any output. I just kept
            >two commented out so I could easily switch addresses for testing,
            >thus the "#"s. It does not kick out any errors and syntax checks
            >valid with tswebeditor (freebie).
            >>
            >I've sprinkled some echoes here and there to try to see what's
            >running but no help. I've indicated the ones that DO echo properly
            >for me with <-------.
            > I've checked syntax and pairing of brackets etc. in two differend
            >IDEs and all looks OK.
            > But, I've obviously pulled something stupid somwehere. It's pretty
            >simple code and I think it's evident what's going on so I haven't yet
            >added many comments. Basically, check the length left and right, how
            >many DOTs and @, and no dots where they shouldn't be.
            > But none of the if's result in any output & don't seem to be
            >getting run, indicating something pretty obvious I'm sure, just not
            >obvious to me!
            >>
            >Any Help?
            >>
            >Twayne
            >>
            >>
            >---------------------
            ><?php
            >$email="mine@d omain.com";
            >#$email="a@b.c ";
            >#$email=".mine .@.domain..com" ;
            >echo "<br/>KB PFSTART"; <------- PFSTART etc are just ts names,
            >nothing more.
            >echo '<br/>using: ' . $email; <------- shows email address correctly
            >>
            >>
            >function validateEmail($ email){
            > $output = "Might be valid.";
            > $email = trim($email);
            >>
            > If ((strlen($email )<5) || strstr($email," "))
            > {
            > $output = "too short, " . strlen($email) . " characters.";
            >echo "<br/>KB PF7";
            > }
            > If (substr_count($ email, "@")<>1)
            > {
            > $output = "<one @.";
            >echo "<br/>KB PF6";
            > }
            > Else
            > {
            > If (strlen($halves[0])<1 || strlen($halves[1])<=3)
            >{
            > $output = "too few characters.";
            > echo "<br/>KB PF5";
            > }
            >echo "<br/>KB PF3";
            > If (substr($halves[0],0,1)=="." || substr($halves[0],-1,1)==".")
            >{
            > $output = " dot just before teh @.";
            >echo "<br/>KB PF5";
            > }
            > If (substr($halves[1],0,1)=="." || substr($halves[1],-1,1)==".")
            >{
            > $output = " dot on end of tld";
            >echo "<br/>KB PF5";
            > }
            > if (!strstr($halve s[1],".") || strstr($halves[1],".."))
            >{
            > $output = " wrong number of dots in it.";
            >echo "<br/>KB PF5";
            > }
            >echo "<br/>KB PF7";
            > }
            > return $output;
            >}
            >echo '<br/>$output is ' . $output; # <--- $OUTPUT DOES NOT ECHO
            >echo "<br/>KB PFEND"; <-------
            >>>
            >--------- end ------------------


            Comment

            • Michael Fesser

              #7
              Re: Function inop, but tosses no errors

              ..oO(Twayne)
              >Maybe a stupid question, but do you actually call this function
              >somewhere?
              >
              >Aww, darn it, yes; I forgot to inlcude the code. It's just a
              >validateEmail( $email) statement after the "--...---" at the bottom of my
              >posted code.
              OK.
              >>echo '<br/>$output is ' . $output; # <--- $OUTPUT DOES NOT ECHO
              >>
              >This line should cause an E_NOTICE error, since $output is not defined
              >anywhere.
              >
              >Nope; and I do have errors turned on, including notices, in .ini.
              >
              >$output is assigned multiple times as the function runs. e.g.
              $output = "Might be valid."; and
              $output = "too short, " . strlen($email) . " characters.";
              Yes, inside the function. But the line I mentioned was _outside_ the
              function. But it's probably in the part you didn't post. ;)

              Problem seems to be solved, but a last question: Did you change anything
              in the PHP configuration? Such changes may require a restart of the web
              server, but not a restart of the whole system. That's a bit strange.

              Micha

              Comment

              • Twayne

                #8
                Re: Function inop, but tosses no errors

                .oO(Twayne)
                >
                >>Maybe a stupid question, but do you actually call this function
                >>somewhere?
                >>
                >Aww, darn it, yes; I forgot to inlcude the code. It's just a
                >validateEmail( $email) statement after the "--...---" at the bottom
                >of my posted code.
                >
                OK.
                >
                >>>echo '<br/>$output is ' . $output; # <--- $OUTPUT DOES NOT ECHO
                >>>
                >>This line should cause an E_NOTICE error, since $output is not
                >>defined anywhere.
                >>
                >Nope; and I do have errors turned on, including notices, in .ini.
                >>
                >$output is assigned multiple times as the function runs. e.g.
                > $output = "Might be valid."; and
                > $output = "too short, " . strlen($email) . " characters.";
                >
                Yes, inside the function. But the line I mentioned was _outside_ the
                function. But it's probably in the part you didn't post. ;)
                OH, I see it. No, It was misplaced; I'd done a lot of rearranging and
                screwed up replacing it properly.
                >
                Problem seems to be solved, but a last question: Did you change
                anything in the PHP configuration? Such changes may require a restart
                of the web server, but not a restart of the whole system. That's a
                bit strange.
                >
                Micha
                Hmm, I don't think so, but ; not exactly sure when I did it or if it
                could count as a config change though: I did add a php.ini to my php
                directory with only a "register_globa ls = off " line in it. AFAIK I
                don't need it; don't even recall why I used it now, I'll have to check
                my notes again. I did not change any config files though (ini, cfg,
                etc).
                However, restarting the server first should probably have been my
                first effort, not the Restart; I'll have to remember that just for GPs.

                Thanks again,

                Twayne






                Comment

                Working...