Space Issue with my PHP page

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

    #1

    Space Issue with my PHP page

    I am a newbie to PHP so hopefully this is a easy question.

    I am pulling data off of one server, which holds our data base and
    posts it to my PHP page.

    I have the following code on my php page:


    $pfirstname = $_POST['NFIRST0'];
    $plastname = $_POST['NLAST0'];
    $paddress = $_POST['NSTREET0'];
    $pxaddress = $_POST['NEXTRAADDRESS0 ']; etc....

    For the $paddress variable, it is skipping anything after a space. For
    example, if the address is 1234 Main, the only data that pulls in to my
    php page would be 1234. It would skip the Main. This is also occuring
    with other variables as well.

    Anyone have any ideas to why this is happening?

  • reandeau

    #2
    Re: Space Issue with my PHP page

    Can you supply more code so I can see see what your script is doing?
    How are you pulling the data off of the server?

    Comment

    • tim

      #3
      Re: Space Issue with my PHP page


      MS wrote:[color=blue]
      > I am a newbie to PHP so hopefully this is a easy question.
      >
      > I am pulling data off of one server, which holds our data base and
      > posts it to my PHP page.
      >
      > I have the following code on my php page:
      >
      >
      > $pfirstname = $_POST['NFIRST0'];
      > $plastname = $_POST['NLAST0'];
      > $paddress = $_POST['NSTREET0'];
      > $pxaddress = $_POST['NEXTRAADDRESS0 ']; etc....
      >
      > For the $paddress variable, it is skipping anything after a space. For
      > example, if the address is 1234 Main, the only data that pulls in to my
      > php page would be 1234. It would skip the Main. This is also occuring
      > with other variables as well.
      >
      > Anyone have any ideas to why this is happening?[/color]

      Hi there

      How are you delivering the data to your page?

      It could be because spaces in post data need to be converted to
      pluses(+) or %32 before delivery

      If you are using php to send the data to the php page then use the
      urlencode function on the data before you post it


      Tim

      Comment

      • Rik

        #4
        Re: Space Issue with my PHP page

        MS wrote:[color=blue]
        > I am a newbie to PHP so hopefully this is a easy question.
        >
        > I am pulling data off of one server, which holds our data base and
        > posts it to my PHP page.
        >
        > I have the following code on my php page:
        >
        >
        > $pfirstname = $_POST['NFIRST0'];
        > $plastname = $_POST['NLAST0'];
        > $paddress = $_POST['NSTREET0'];
        > $pxaddress = $_POST['NEXTRAADDRESS0 ']; etc....
        >
        > For the $paddress variable, it is skipping anything after a space.
        > For example, if the address is 1234 Main, the only data that pulls in
        > to my php page would be 1234. It would skip the Main. This is also
        > occuring with other variables as well.
        >
        > Anyone have any ideas to why this is happening?[/color]

        I'd think the posting goes wrong, have you got a snippet of code from that
        side?

        What does print_r($_POST) ; say?

        If $_POST['NSTREET0'] does have to right value, are you sure not casting
        $paddress to an integer somewhere?

        Grtz,
        --
        Rik Wasmus


        Comment

        • Geoff Muldoon

          #5
          Re: Space Issue with my PHP page

          mscurto@gmail.c om says...
          [color=blue]
          > For the $paddress variable, it is skipping anything after a space. For
          > example, if the address is 1234 Main, the only data that pulls in to my
          > php page would be 1234. It would skip the Main. This is also occuring
          > with other variables as well.
          >
          > Anyone have any ideas to why this is happening?[/color]

          Yes, It's a HTML issue not a PHP one. You need to double-quote any
          strings with spaces in your inputs.

          Example:
          echo "<input type=hidden name=paddress value=$paddress >";
          should be changed to
          echo "<input type=hidden name=paddress value=/"$paddress/">";
          or
          echo '<input type=hidden name=paddress value="$paddres s">';

          GM

          Comment

          • Rik

            #6
            Re: Space Issue with my PHP page

            Hmmmz, it's getting late for you I think....

            Geoff Muldoon wrote:[color=blue]
            > Example:
            > echo "<input type=hidden name=paddress value=$paddress >";
            > should be changed to
            > echo "<input type=hidden name=paddress value=/"$paddress/">";[/color]

            You mean:
            echo "<input type=hidden name=paddress value=\"$paddre ss\">";
            [color=blue]
            > echo '<input type=hidden name=paddress value="$paddres s">';[/color]

            You mean:
            echo '<input type=hidden name=paddress value="'.$paddr ess.'">';
            or:
            echo "<input type=hidden name=paddress value='$paddres s'>";

            And now we're busy. just as well put quotes around hidden: couldn't hurt,
            and it's a good habit to quote all the attribute-values regardless wether it
            is really necessary or not.

            Grtz,
            --
            Rik Wasmus


            Comment

            • Geoff Muldoon

              #7
              Re: Space Issue with my PHP page

              In article <e4dq6d$37e$1@n etlx020.civ.utw ente.nl>,
              luiheidsgoeroe@ hotmail.com says...[color=blue]
              > Hmmmz, it's getting late for you I think....
              >
              > Geoff Muldoon wrote:[color=green]
              > > Example:
              > > echo "<input type=hidden name=paddress value=$paddress >";
              > > should be changed to
              > > echo "<input type=hidden name=paddress value=/"$paddress/">";[/color]
              >
              > You mean:
              > echo "<input type=hidden name=paddress value=\"$paddre ss\">";
              >[color=green]
              > > echo '<input type=hidden name=paddress value="$paddres s">';[/color]
              >
              > You mean:
              > echo '<input type=hidden name=paddress value="'.$paddr ess.'">';
              > or:
              > echo "<input type=hidden name=paddress value='$paddres s'>";
              >
              > And now we're busy. just as well put quotes around hidden: couldn't hurt,
              > and it's a good habit to quote all the attribute-values regardless wether it
              > is really necessary or not.[/color]

              Oops, not enough coffee, thanks for the corrections.

              Comment

              • Toby Inkster

                #8
                Re: Space Issue with my PHP page

                tim wrote:
                [color=blue]
                > It could be because spaces in post data need to be converted to
                > pluses(+) or %32 before delivery[/color]

                %20, not %32.

                <?php
                print urldecode('%32' ); // prints '2'.
                ?>

                --
                Toby A Inkster BSc (Hons) ARCS
                Contact Me ~ http://tobyinkster.co.uk/contact

                Comment

                • tim

                  #9
                  Re: Space Issue with my PHP page


                  Toby Inkster wrote:[color=blue]
                  > tim wrote:
                  >[color=green]
                  > > It could be because spaces in post data need to be converted to
                  > > pluses(+) or %32 before delivery[/color]
                  >
                  > %20, not %32.
                  >
                  > <?php
                  > print urldecode('%32' ); // prints '2'.
                  > ?>
                  >[/color]

                  Oops I forgot to convert to hex, thank you for the reminder.

                  Tim

                  Comment

                  • MS

                    #10
                    Re: Space Issue with my PHP page

                    Thanks for all the postings, I got it working.

                    Comment

                    Working...