Two systems->Two results

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

    Two systems->Two results

    I'm just beginning my PHP studies and one of the first tutorials gives
    different results. The user is prompted for a Name, and PHP is to say
    "Welcome <name>!" on another page. On my hosted server the example works
    fine, but on my own machine the message "Welcome !" is displayed,
    instead of "Welcome James!" (or whatever). The code:

    hello-web.htm

    <form action="hello-web.php" method="post">
    <td>Name:</td>
    <td><input type="text" name="frmName" size="24">
    <input type="submit" value="Submit">
    </form>


    hello-web.php

    <p>Hello
    <?php echo($frmName); ?>!


    And from the log:

    [client 127.0.0.1] PHP Notice: Undefined variable: frmName in
    C:\\wwwroot\\ph pdev\\hello-web.php on line 2, referer:


    The host system is using an older version of PHP and Apache, but I would
    think the problem is something else. Anyone have an idea? Thanks.

    James
  • Anthony Dodds

    #2
    Re: Two systems-&gt;Two results

    register globals issue

    in hello-web.php replace $frmName with $_POST['frmName']

    Regards And good luck

    Anthony
    "James" <jmessick@triad .rr.com> wrote in message
    news:0se3f.1248 $Sg2.199921@twi ster.southeast. rr.com...[color=blue]
    > I'm just beginning my PHP studies and one of the first tutorials gives
    > different results. The user is prompted for a Name, and PHP is to say
    > "Welcome <name>!" on another page. On my hosted server the example works
    > fine, but on my own machine the message "Welcome !" is displayed, instead
    > of "Welcome James!" (or whatever). The code:
    >
    > hello-web.htm
    >
    > <form action="hello-web.php" method="post">
    > <td>Name:</td>
    > <td><input type="text" name="frmName" size="24">
    > <input type="submit" value="Submit">
    > </form>
    >
    >
    > hello-web.php
    >
    > <p>Hello
    > <?php echo($frmName); ?>!
    >
    >
    > And from the log:
    >
    > [client 127.0.0.1] PHP Notice: Undefined variable: frmName in
    > C:\\wwwroot\\ph pdev\\hello-web.php on line 2, referer:
    > http://localhost/phpdev/hello-web.htm
    >
    > The host system is using an older version of PHP and Apache, but I would
    > think the problem is something else. Anyone have an idea? Thanks.
    >
    > James[/color]


    Comment

    • James

      #3
      Re: Two systems-&gt;Two results

      Anthony Dodds wrote:[color=blue]
      > register globals issue
      >
      > in hello-web.php replace $frmName with $_POST['frmName']
      >
      > Regards And good luck
      >
      > Anthony
      > "James" <jmessick@triad .rr.com> wrote in message
      > news:0se3f.1248 $Sg2.199921@twi ster.southeast. rr.com...
      >[color=green]
      >>I'm just beginning my PHP studies and one of the first tutorials gives
      >>different results. The user is prompted for a Name, and PHP is to say
      >>"Welcome <name>!" on another page. On my hosted server the example works
      >>fine, but on my own machine the message "Welcome !" is displayed, instead
      >>of "Welcome James!" (or whatever). The code:
      >>
      >>hello-web.htm
      >>
      >><form action="hello-web.php" method="post">
      >> <td>Name:</td>
      >> <td><input type="text" name="frmName" size="24">
      >><input type="submit" value="Submit">
      >></form>
      >>
      >>
      >>hello-web.php
      >>
      >><p>Hello
      >><?php echo($frmName); ?>!
      >>
      >>
      >>And from the log:
      >>
      >>[client 127.0.0.1] PHP Notice: Undefined variable: frmName in
      >>C:\\wwwroot\\ phpdev\\hello-web.php on line 2, referer:
      >>http://localhost/phpdev/hello-web.htm
      >>
      >>The host system is using an older version of PHP and Apache, but I would
      >>think the problem is something else. Anyone have an idea? Thanks.
      >>
      >>James[/color]
      >
      >
      >[/color]

      Simply amazing! So I guess it was the difference between PHP 5.0.4 on my
      local dev system and PHP 4.3.3 on my host. Thanks for the help!

      So where's a good PHP tutorial? I mainly want to write a system to
      interact with a MySQL database and produce some web pages with the
      contents of same.

      James

      Comment

      • Gordon Burditt

        #4
        Re: Two systems-&gt;Two results

        >I'm just beginning my PHP studies and one of the first tutorials gives[color=blue]
        >different results. The user is prompted for a Name, and PHP is to say
        >"Welcome <name>!" on another page. On my hosted server the example works
        >fine, but on my own machine the message "Welcome !" is displayed,
        >instead of "Welcome James!" (or whatever). The code:[/color]

        A POST variable is referenced as $_POST['frmName'].
        With reasonably non-ancient versions of PHP, this should work
        correctly on both your version and the one used by your host.

        Gordon L. Burditt
        [color=blue]
        >hello-web.htm
        >
        ><form action="hello-web.php" method="post">
        > <td>Name:</td>
        > <td><input type="text" name="frmName" size="24">
        ><input type="submit" value="Submit">
        ></form>
        >
        >
        >hello-web.php
        >
        ><p>Hello
        > <?php echo($frmName); ?>!
        >
        >
        >And from the log:
        >
        >[client 127.0.0.1] PHP Notice: Undefined variable: frmName in
        >C:\\wwwroot\\p hpdev\\hello-web.php on line 2, referer:
        >http://localhost/phpdev/hello-web.htm
        >
        >The host system is using an older version of PHP and Apache, but I would
        >think the problem is something else. Anyone have an idea? Thanks.
        >
        >James[/color]


        Comment

        • Kirsten

          #5
          Re: Two systems-&gt;Two results

          James schrieb:[color=blue]
          >
          > Simply amazing! So I guess it was the difference between PHP 5.0.4 on my
          > local dev system and PHP 4.3.3 on my host. Thanks for the help!
          >[/color]
          The difference could be that your host had been set 'register_globa ls'
          on in the php.ini.[color=blue]
          > So where's a good PHP tutorial? I mainly want to write a system to
          > interact with a MySQL database and produce some web pages with the
          > contents of same.
          >
          > James[/color]

          Kirsten

          Comment

          • Geoff Berrow

            #6
            Re: Two systems-&gt;Two results

            I noticed that Message-ID:
            <q7j3f.2121$pP1 .179051@twister .southeast.rr.c om> from James contained
            the following:
            [color=blue]
            >So where's a good PHP tutorial? I mainly want to write a system to
            >interact with a MySQL database and produce some web pages with the
            >contents of same.[/color]

            Trouble is, if you know how to do it you don't go looking at tutorials.
            :-(

            I used the Webmonkey tutorial when I first started, but that is out of
            date. I'll have another look round when I get time. Ought to write one
            really because a lot of students on my introduction to PHP course often
            want to progress. Of course, then you are looking at a lot more stuff,
            SQL and the whole relational database thing.

            --
            Geoff Berrow (put thecat out to email)
            It's only Usenet, no one dies.
            My opinions, not the committee's, mine.
            Simple RFDs http://www.ckdog.co.uk/rfdmaker/

            Comment

            • James

              #7
              Re: Two systems-&gt;Two results

              Kirsten wrote:[color=blue]
              > James schrieb:
              >[color=green]
              >>Simply amazing! So I guess it was the difference between PHP 5.0.4 on my
              >>local dev system and PHP 4.3.3 on my host. Thanks for the help!
              >>[/color]
              >
              > The difference could be that your host had been set 'register_globa ls'
              > on in the php.ini.[/color]

              Yes, turning register_global s on in php.ini on my local machine fixed
              the problem also!

              Comment

              • James

                #8
                Re: Two systems-&gt;Two results

                Geoff Berrow wrote:[color=blue]
                > I noticed that Message-ID:
                > <q7j3f.2121$pP1 .179051@twister .southeast.rr.c om> from James contained
                > the following:
                >
                >[color=green]
                >>So where's a good PHP tutorial? I mainly want to write a system to
                >>interact with a MySQL database and produce some web pages with the
                >>contents of same.[/color]
                >
                >
                > Trouble is, if you know how to do it you don't go looking at tutorials.
                > :-(
                >
                > I used the Webmonkey tutorial when I first started, but that is out of
                > date. I'll have another look round when I get time. Ought to write one
                > really because a lot of students on my introduction to PHP course often
                > want to progress. Of course, then you are looking at a lot more stuff,
                > SQL and the whole relational database thing.
                >[/color]

                I have a lot of history working with databases, Oracle mostly, just not
                MySQL. I have played with Cold Fusion and Access a little bit, but
                wanted to build up my skills with Open Source alternatives.

                Comment

                • Geoff Berrow

                  #9
                  Re: Two systems-&gt;Two results

                  I noticed that Message-ID:
                  <qLy3f.4008$pP1 .217358@twister .southeast.rr.c om> from James contained
                  the following:
                  [color=blue][color=green]
                  >> The difference could be that your host had been set 'register_globa ls'
                  >> on in the php.ini.[/color]
                  >
                  >Yes, turning register_global s on in php.ini on my local machine fixed
                  >the problem also![/color]

                  This is a bad idea. If you write scripts that will run with register
                  globals off, they will run on a server with register globals on. The
                  reverse is not true.
                  --
                  Geoff Berrow (put thecat out to email)
                  It's only Usenet, no one dies.
                  My opinions, not the committee's, mine.
                  Simple RFDs http://www.ckdog.co.uk/rfdmaker/

                  Comment

                  Working...