2nd pair of eyes, simple ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • one man army

    2nd pair of eyes, simple ?

    I read a chapter of a book. I tried this. Its not doing what I thought
    it should. Why?

    <?
    $zipRaw = $_GET['zipRaw_name'];
    if ( !empty($zipRaw) ) {

    $valid = $zValid = checkLength($zi pRaw, 1, 5);

    if ($valid) {
    header( "Location:h ttp://www.yahoo.com") ;
    exit;
    } else {
    echo( "<html><hea d></head><body> zipRaw = ");
    echo( $zipRaw );
    echo( " <br></body>" );
    }
    }
    ?>


    I get

    zipRaw = "); echo( $zipRaw ); echo( "
    " ); } } ?>

    in the Browser window. Same if I change echo to print().
    And header() never works, ever, even if I just add it as the first line,
    no conditional tests. call me clueless. its late. TIA
  • Steve

    #2
    Re: 2nd pair of eyes, simple ?

    [color=blue]
    > Its not doing what I thought it should. Why?[/color]
    [color=blue]
    > $valid = $zValid = checkLength($zi pRaw, 1, 5);[/color]

    So, what is checkLength() ? It isn't defined in the code you posted, it
    isn't a built-in PHP function, you haven't included any other source,
    so I wonder if you posted the actual code you are having problems with.

    ---
    Steve

    Comment

    • Kimmo Laine

      #3
      Re: 2nd pair of eyes, simple ?

      "one man army" <newsAT@screenl ightDOT.com> kirjoitti
      viestissä:newsA T-8D1654.00200221 012006@newsclst r02.news.prodig y.com...[color=blue]
      > I get
      >
      > zipRaw = "); echo( $zipRaw ); echo( "
      > " ); } } ?>
      >
      > in the Browser window.[/color]

      And you are sure that php is executed? if you look at the source code, not
      just the browser window, what do you see? To me it would seem at first that
      php is not executed and the browser simply displays what it can make of the
      raw php source code.

      --
      SETI @ Home - Donate your cpu's idle time to science.
      Further reading at <http://setiweb.ssl.ber keley.edu/>
      Kimmo Laine <antaatulla.sik anautaa@gmail.c om.NOSPAM.inval id>


      Comment

      • Jerry Stuckle

        #4
        Re: 2nd pair of eyes, simple ?

        one man army wrote:[color=blue]
        > I read a chapter of a book. I tried this. Its not doing what I thought
        > it should. Why?
        >
        > <?
        > $zipRaw = $_GET['zipRaw_name'];
        > if ( !empty($zipRaw) ) {
        >
        > $valid = $zValid = checkLength($zi pRaw, 1, 5);
        >
        > if ($valid) {
        > header( "Location:h ttp://www.yahoo.com") ;
        > exit;
        > } else {
        > echo( "<html><hea d></head><body> zipRaw = ");
        > echo( $zipRaw );
        > echo( " <br></body>" );
        > }
        > }
        > ?>
        >
        >
        > I get
        >
        > zipRaw = "); echo( $zipRaw ); echo( "
        > " ); } } ?>
        >
        > in the Browser window. Same if I change echo to print().
        > And header() never works, ever, even if I just add it as the first line,
        > no conditional tests. call me clueless. its late. TIA[/color]

        Maybe short tags is turned off. Try using

        <?php

        at the start instead.

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

        Comment

        • one man army

          #5
          Re: 2nd pair of eyes, simple ?

          <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
          "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">

          <?php
          $debug=0;
          ini_set('displa y_errors', 1);
          ini_set('safe_m ode', 'FALSE');

          error_reporting (E_ALL & ~E_NOTICE);
          ?>

          <?php
          $zipRaw = $_GET['zipRaw_name'];
          if ( !empty($zipRaw) ) {

          $valid = $zValid = true; //checkLength($zi pRaw, 1, 5);

          if ($valid) {
          header( "Location:h ttp://www.yahoo.com") ;
          exit;
          } else {
          echo( "<html><hea d></head><body> zipRaw = ");
          echo( $zipRaw );
          echo( " <br></body>" );
          }
          }
          ?>

          -------- or print() in place of echo()

          verbatim, same results. The Browser shows


          zipRaw = "); echo( $zipRaw ); echo( "
          " ); } } ?>

          Comment

          • Kimmo Laine

            #6
            Re: 2nd pair of eyes, simple ?

            "one man army" <newsAT@screenl ightDOT.com> kirjoitti
            viestissä:newsA T-93926C.08475321 012006@newsclst r02.news.prodig y.com...[color=blue]
            > <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
            > "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
            >
            > <?php
            > $debug=0;
            > ini_set('displa y_errors', 1);
            > ini_set('safe_m ode', 'FALSE');
            >
            > error_reporting (E_ALL & ~E_NOTICE);
            > ?>
            >
            > <?php
            > $zipRaw = $_GET['zipRaw_name'];
            > if ( !empty($zipRaw) ) {
            >
            > $valid = $zValid = true; //checkLength($zi pRaw, 1, 5);
            >
            > if ($valid) {
            > header( "Location:h ttp://www.yahoo.com") ;
            > exit;
            > } else {
            > echo( "<html><hea d></head><body> zipRaw = ");
            > echo( $zipRaw );
            > echo( " <br></body>" );
            > }
            > }
            > ?>
            >
            > -------- or print() in place of echo()
            >
            > verbatim, same results. The Browser shows
            >
            >
            > zipRaw = "); echo( $zipRaw ); echo( "
            > " ); } } ?>[/color]

            The header won't work because the code sends output before setting the
            header. (Headers must be set before any outpyt, and the doctype is the first
            output you send. On the other hand, it doesn't give you error of headers
            already been sent therefore I submit that your php code is never executed
            for one reason or another. Like I already said once, check the SOURCE CODE
            when you view the result in the browser - I bet that you see the original
            php code as it is.

            --
            SETI @ Home - Donate your cpu's idle time to science.
            Further reading at <http://setiweb.ssl.ber keley.edu/>
            Kimmo Laine <antaatulla.sik anautaa@gmail.c om.NOSPAM.inval id>


            Comment

            • Steve

              #7
              Re: 2nd pair of eyes, simple ?

              [color=blue]
              > <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
              > "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
              >
              > <?php
              > $debug=0;
              > ini_set('displa y_errors', 1);
              > ini_set('safe_m ode', 'FALSE');
              >
              > error_reporting (E_ALL & ~E_NOTICE);
              > ?>
              >
              > <?php
              > $zipRaw = $_GET['zipRaw_name'];
              > if ( !empty($zipRaw) ) {
              >
              > $valid = $zValid = true; //checkLength($zi pRaw, 1, 5);
              >
              > if ($valid) {
              > header( "Location:h ttp://www.yahoo.com") ;
              > exit;
              > } else {
              > echo( "<html><hea d></head><body> zipRaw = ");
              > echo( $zipRaw );
              > echo( " <br></body>" );
              > }
              > }
              > ?>
              >
              > -------- or print() in place of echo()
              >
              > verbatim, same results. The Browser shows
              >
              >
              > zipRaw = "); echo( $zipRaw ); echo( "
              > " ); } } ?>[/color]

              PLEASE confirm that (1) the document has a .php extension, and (2) you
              are requesting it from a PHP enabled web server.

              I mean, clueless is one thing but...

              ---
              Steve

              Comment

              • one man army

                #8
                Re: 2nd pair of eyes, simple ?

                In article <dqtuto$nc2$1@p hys-news4.kolumbus. fi>,
                "Kimmo Laine" <spam@outolempi .net> wrote:
                [color=blue]
                > "one man army" <newsAT@screenl ightDOT.com> kirjoitti
                > viestissä:newsA T-93926C.08475321 012006@newsclst r02.news.prodig y.com...[color=green]
                > > <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                > > "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
                > >[/color][/color]

                Oh! the Doctype counts. I did not see that anywhere. (thanks Kimmo)

                also, the file is called index.html. I would like to keep that. Is
                there a place that spells out the rules for when it is ok to have
                xx.html and when I need to use xxx.php? It seems like the code is just
                not executing. What else do I need to make sure of?

                I am using PHP Version 4.4.0.
                [color=blue][color=green]
                > > <?php
                > > $debug=0;
                > > ini_set('displa y_errors', 1);
                > > ini_set('safe_m ode', 'FALSE');
                > >
                > > error_reporting (E_ALL & ~E_NOTICE);
                > > ?>
                > >
                > > <?php
                > > $zipRaw = $_GET['zipRaw_name'];
                > > if ( !empty($zipRaw) ) {
                > >
                > > $valid = $zValid = true; //checkLength($zi pRaw, 1, 5);
                > >
                > > if ($valid) {
                > > header( "Location:h ttp://www.yahoo.com") ;
                > > exit;
                > > } else {
                > > echo( "<html><hea d></head><body> zipRaw = ");
                > > echo( $zipRaw );
                > > echo( " <br></body>" );
                > > }
                > > }
                > > ?>
                > >
                > > -------- or print() in place of echo()
                > >
                > > verbatim, same results. The Browser shows
                > >
                > >
                > > zipRaw = "); echo( $zipRaw ); echo( "
                > > " ); } } ?>[/color]
                >
                > The header won't work because the code sends output before setting the
                > header. (Headers must be set before any outpyt, and the doctype is the first
                > output you send. On the other hand, it doesn't give you error of headers
                > already been sent therefore I submit that your php code is never executed
                > for one reason or another. Like I already said once, check the SOURCE CODE
                > when you view the result in the browser - I bet that you see the original
                > php code as it is.[/color]

                Comment

                • Jerry Stuckle

                  #9
                  Re: 2nd pair of eyes, simple ?

                  one man army wrote:[color=blue]
                  > In article <dqtuto$nc2$1@p hys-news4.kolumbus. fi>,
                  > "Kimmo Laine" <spam@outolempi .net> wrote:
                  >
                  >[color=green]
                  >>"one man army" <newsAT@screenl ightDOT.com> kirjoitti
                  >>viestissä:new sAT-93926C.08475321 012006@newsclst r02.news.prodig y.com...
                  >>[color=darkred]
                  >>><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                  >>> "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
                  >>>[/color][/color]
                  >
                  > Oh! the Doctype counts. I did not see that anywhere. (thanks Kimmo)
                  >
                  > also, the file is called index.html. I would like to keep that. Is
                  > there a place that spells out the rules for when it is ok to have
                  > xx.html and when I need to use xxx.php? It seems like the code is just
                  > not executing. What else do I need to make sure of?
                  >
                  > I am using PHP Version 4.4.0.
                  >
                  >[color=green][color=darkred]
                  >>><?php
                  >>>$debug=0;
                  >>>ini_set('dis play_errors', 1);
                  >>>ini_set('saf e_mode', 'FALSE');
                  >>>
                  >>>error_report ing(E_ALL & ~E_NOTICE);
                  >>>?>
                  >>>
                  >>><?php
                  >>>$zipRaw = $_GET['zipRaw_name'];
                  >>>if ( !empty($zipRaw) ) {
                  >>>
                  >>> $valid = $zValid = true; //checkLength($zi pRaw, 1, 5);
                  >>>
                  >>> if ($valid) {
                  >>> header( "Location:h ttp://www.yahoo.com") ;
                  >>> exit;
                  >>> } else {
                  >>> echo( "<html><hea d></head><body> zipRaw = ");
                  >>> echo( $zipRaw );
                  >>> echo( " <br></body>" );
                  >>> }
                  >>>}
                  >>>?>
                  >>>
                  >>>-------- or print() in place of echo()
                  >>>
                  >>>verbatim, same results. The Browser shows
                  >>>
                  >>>
                  >>>zipRaw = "); echo( $zipRaw ); echo( "
                  >>>" ); } } ?>[/color]
                  >>
                  >>The header won't work because the code sends output before setting the
                  >>header. (Headers must be set before any outpyt, and the doctype is the first
                  >>output you send. On the other hand, it doesn't give you error of headers
                  >>already been sent therefore I submit that your php code is never executed
                  >>for one reason or another. Like I already said once, check the SOURCE CODE
                  >>when you view the result in the browser - I bet that you see the original
                  >>php code as it is.[/color][/color]

                  That explains it.

                  You either need to use a .php extension, or you need to change your
                  Apache configuration to parse .html files as php code. But that will
                  cause ALL .html files to be parsed, whether they contain php code or not.


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

                  Comment

                  • one man army

                    #10
                    Re: 2nd pair of eyes, simple ?

                    In article <Z7CdnRxLk-VvA0_eRVn-jQ@comcast.com> ,
                    Jerry Stuckle <jstucklex@attg lobal.net> wrote:
                    [color=blue][color=green][color=darkred]
                    > >>><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                    > >>> "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">[/color]
                    > >
                    > > Oh! the Doctype counts. I did not see that anywhere. (thanks Kimmo)
                    > >
                    > > also, the file is called index.html. I would like to keep that.
                    > > .....[/color]
                    >
                    > That explains it.
                    >
                    > You either need to use a .php extension, or you need to change your
                    > Apache configuration to parse .html files as php code. But that will
                    > cause ALL .html files to be parsed, whether they contain php code or not.[/color]


                    hmmm, that's why I asked about the 'rules'. Because I have had
                    snippets of PHP inline in the files so far, and it works. That's
                    confusing.

                    Perhaps the first chars of the file determine whether HTML or PHP
                    extension is needed? Where is this documented?

                    Comment

                    • Jerry Stuckle

                      #11
                      Re: 2nd pair of eyes, simple ?

                      one man army wrote:[color=blue]
                      > In article <Z7CdnRxLk-VvA0_eRVn-jQ@comcast.com> ,
                      > Jerry Stuckle <jstucklex@attg lobal.net> wrote:
                      >
                      >[color=green][color=darkred]
                      >>>>><!DOCTYP E html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                      >>>>> "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
                      >>>
                      >>>Oh! the Doctype counts. I did not see that anywhere. (thanks Kimmo)
                      >>>
                      >>> also, the file is called index.html. I would like to keep that.
                      >>> .....[/color]
                      >>
                      >>That explains it.
                      >>
                      >>You either need to use a .php extension, or you need to change your
                      >>Apache configuration to parse .html files as php code. But that will
                      >>cause ALL .html files to be parsed, whether they contain php code or not.[/color]
                      >
                      >
                      >
                      > hmmm, that's why I asked about the 'rules'. Because I have had
                      > snippets of PHP inline in the files so far, and it works. That's
                      > confusing.
                      >
                      > Perhaps the first chars of the file determine whether HTML or PHP
                      > extension is needed? Where is this documented?[/color]

                      Nope. It's the file extension that Apache or IIS use to determine
                      whether the file is to be parsed as php, asp or whatever.


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

                      Comment

                      • Jim Michaels

                        #12
                        Re: 2nd pair of eyes, simple ?


                        "Kimmo Laine" <spam@outolempi .net> wrote in message
                        news:dqtuto$nc2 $1@phys-news4.kolumbus. fi...[color=blue]
                        > "one man army" <newsAT@screenl ightDOT.com> kirjoitti
                        > viestissä:newsA T-93926C.08475321 012006@newsclst r02.news.prodig y.com...[color=green]
                        >> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                        >> "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
                        >>
                        >> <?php
                        >> $debug=0;
                        >> ini_set('displa y_errors', 1);
                        >> ini_set('safe_m ode', 'FALSE');
                        >>
                        >> error_reporting (E_ALL & ~E_NOTICE);
                        >> ?>
                        >>
                        >> <?php
                        >> $zipRaw = $_GET['zipRaw_name'];
                        >> if ( !empty($zipRaw) ) {
                        >>
                        >> $valid = $zValid = true; //checkLength($zi pRaw, 1, 5);
                        >>
                        >> if ($valid) {
                        >> header( "Location:h ttp://www.yahoo.com") ;[/color][/color]

                        try inserting a space between Location: and http

                        also, your header call should come before any HTML or a blank line is
                        displayed. your <?php with the header call should be at the tippy top of
                        the file.
                        once the broswer sees a blank line or HTML, that's it - headers are over.

                        [color=blue][color=green]
                        >> exit;
                        >> } else {
                        >> echo( "<html><hea d></head><body> zipRaw = ");
                        >> echo( $zipRaw );
                        >> echo( " <br></body>" );
                        >> }
                        >> }
                        >> ?>
                        >>
                        >> -------- or print() in place of echo()
                        >>
                        >> verbatim, same results. The Browser shows
                        >>
                        >>
                        >> zipRaw = "); echo( $zipRaw ); echo( "
                        >> " ); } } ?>[/color]
                        >
                        > The header won't work because the code sends output before setting the
                        > header. (Headers must be set before any outpyt, and the doctype is the
                        > first output you send. On the other hand, it doesn't give you error of
                        > headers already been sent therefore I submit that your php code is never
                        > executed for one reason or another. Like I already said once, check the
                        > SOURCE CODE when you view the result in the browser - I bet that you see
                        > the original php code as it is.
                        >
                        > --
                        > SETI @ Home - Donate your cpu's idle time to science.
                        > Further reading at <http://setiweb.ssl.ber keley.edu/>
                        > Kimmo Laine <antaatulla.sik anautaa@gmail.c om.NOSPAM.inval id>
                        >[/color]


                        Comment

                        Working...