post of fetched value fails

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

    #1

    post of fetched value fails

    I have a MySql db, in which I search for values to populate a selection
    box, as follows :

    <select size="1" name="customer" >
    <option selected="selec ted">(not queried)</option>
    <?php while($nt=mysql _fetch_array($r esult2)){
    echo "<option value=$nt[customer]>$nt[customer]</option>\n";}
    ?>
    </select>

    This works fine, all the customers appear with their complete names,
    including spaces if there are.

    When I do a submit of the php page containing this part of code and in
    this page I do a

    $customer=$_POS T['customer'];

    then the value of $customer is cutted to the first <blank(space)
    encountered.

    E,g, : if in the selection box the customer name John Smith appears,
    then I get in the result page after the submission as customer=John

    When I make a selection box, with fixed populated values (so values not
    fetched from the db) then after the submission, I get the correct info
    (values are not cutted to the first space).

    Is there anybody out there that can give a solution for this strange
    (to me) behaviour ? It would be uttermost appreciated !

  • Erwin Moller

    #2
    Re: post of fetched value fails

    rukkie wrote:
    I have a MySql db, in which I search for values to populate a selection
    box, as follows :
    >
    <select size="1" name="customer" >
    <option selected="selec ted">(not queried)</option>
    Hi Rukkie,

    That is wrong.
    selected="selec ted" in nonsense.

    If you want to select an option in a selectbox, you only use the word
    SELECTED, and don't give it a value.

    You'll have to produces something like this:
    <SELECT name="customer" >
    <OPTION value="bla1">bl a1
    <OPTION value="bla2" SELECTED>bla2
    <OPTION value="bla3">bl a3
    </SELECT>

    In your code none of the options have a value.

    I would advise you to FIRST learn how HTML and FORMS works, then start PHP.

    Regards,
    Erwin Moller

    <?php while($nt=mysql _fetch_array($r esult2)){
    echo "<option value=$nt[customer]>$nt[customer]</option>\n";}
    ?>
    </select>
    >
    This works fine, all the customers appear with their complete names,
    including spaces if there are.
    >
    When I do a submit of the php page containing this part of code and in
    this page I do a
    >
    $customer=$_POS T['customer'];
    >
    then the value of $customer is cutted to the first <blank(space)
    encountered.
    >
    E,g, : if in the selection box the customer name John Smith appears,
    then I get in the result page after the submission as customer=John
    >
    When I make a selection box, with fixed populated values (so values not
    fetched from the db) then after the submission, I get the correct info
    (values are not cutted to the first space).
    >
    Is there anybody out there that can give a solution for this strange
    (to me) behaviour ? It would be uttermost appreciated !

    Comment

    • Pedro Graca

      #3
      Re: post of fetched value fails

      rukkie wrote:
      <?php while($nt=mysql _fetch_array($r esult2)){
      echo "<option value=$nt[customer]>$nt[customer]</option>\n";}
      ?>
      [...]
      When I make a selection box, with fixed populated values (so values not
      fetched from the db) then after the submission, I get the correct info
      (values are not cutted to the first space).
      >
      Is there anybody out there that can give a solution for this strange
      (to me) behaviour ? It would be uttermost appreciated !

      What's the difference between the PHP generated HTML and the one with
      fixed populated values?

      I'm guessing PHP does

      <option value=John Smith>John Smith</option>

      whereas the fixed value is

      <option value="John Smith">John Smith</option>

      Notice the quotes on the second line?

      --
      File not found: (R)esume, (R)etry, (R)erun, (R)eturn, (R)eboot

      Comment

      • usenet+2004@john.dunlop.name

        #4
        Re: post of fetched value fails

        Erwin Moller:
        selected="selec ted" in nonsense.
        "Full" attribute specifications are valid in both HTML and XHTML.
        XHTML actually requires them, since attribute minimisation is not
        allowed. I don't know how seriously you should take the somewhat dated
        claim that 'many user agents only recognize the minimized form of
        boolean attributes and not the full form' (HTML4.01, sec. B.3.4).

        The problem is that the attribute value isn't quoted:

        | echo "<option value=$nt[customer]>$nt[customer]</option>\n";}

        In HTML only Name characters (i.e., [a-zA-Z0-9._:-]) can occur
        unquoted, and in XHTML all attribute values must be quoted. Browser
        error recovery probably means the first Name token is taken as the
        value, so anything after the first non-Name character is ignored.

        --
        Jock

        Comment

        • rukkie

          #5
          Re: post of fetched value fails

          Thanks for all the replies .....

          The problem is solved, it was indeed a "quotes" problem

          The code that works is :

          <select size="1" name="customer" >
          <option selected="selec ted">(not queried)</option>
          <?php while($nt=mysql _fetch_array($r esult2)){
          echo "<option
          value=\"$nt[customer]\">$nt[customer]</option>\n";} ?>
          </select>

          Note the \" in the option value statement ....

          Comment

          • ZabMilenko

            #6
            Re: post of fetched value fails


            Erwin Moller wrote:
            >
            I would advise you to FIRST learn how HTML and FORMS works,
            then start PHP.
            >
            That's not a very nice way to tell someone they are wrong.

            The long form of attributes has been allowed since AT LEAST html 3.0. You
            can verify this by going to http://www.w3.org/MarkUp/html3/html3.dtd and
            reading the doctype. Hint: text search for "nowrap" and "selected". Both
            of them allow the default value of "nowrap" and "selected", respectively.
            This is a fall-over from SGML, and EVERY browser since Netscape 3.2 has
            supported it.

            Comment

            • usenet+2004@john.dunlop.name

              #7
              Re: post of fetched value fails

              ZabMilenko:
              The long form of attributes has been allowed since AT LEAST html 3.0.
              Yes. In fact HTML has always allowed "full" attribute specifications.

              Attribute specification minimisation - e.g., <OPTION selected- is an
              optional feature, indicated by SHORTTAG YES in the SGML declaration.
              EVERY browser since Netscape 3.2 has supported it.
              That's a big claim.

              According to HTML4.01 (now 7 years old), 'many user agents only
              recognize the minimized form of boolean attributes and not the full
              form'.

              --
              Jock

              Comment

              • Pedro Graca

                #8
                Re: post of fetched value fails

                rukkie wrote:
                [...]
                echo "<option
                value=\"$nt[customer]\">$nt[customer]</option>\n";} ?>
                >
                Note the \" in the option value statement ....
                You can do that or use single quotes to quote the value

                echo "<option value='$nt[customer]'>$nt[customer]</option>\n";

                --
                File not found: (R)esume, (R)etry, (R)erun, (R)eturn, (R)eboot

                Comment

                • Erwin Moller

                  #9
                  Re: post of fetched value fails

                  ZabMilenko wrote:
                  >
                  Erwin Moller wrote:
                  >
                  I would advise you to FIRST learn how HTML and FORMS works,
                  then start PHP.
                  >
                  >
                  That's not a very nice way to tell someone they are wrong.
                  >
                  Hi,

                  True,

                  I didn't mean it that harsh as it sounded.
                  Sorry rukkie!

                  Regards,
                  Erwin Moller

                  Comment

                  • ZabMilenko

                    #10
                    Re: post of fetched value fails


                    Yes you are right. It is a fairly big claim, and I could very well be wrong
                    about it.

                    I was kind of basing it off of IE3, Netscape3, Mosaic 2.1, and Opera 2.1,
                    all of which came out in 1996. HTML 3 was written in 1997 if I recall
                    correctly. Netscape was largely responsible for the changes from HTML2 to
                    3, so I kind of used them as a milestone. Since HTML4.0 was already on the
                    drawing board when HTML3 came out, most browsers shot for compliance at that
                    level.

                    The three browsers I can't say for sure on are AOL's bundled browser circa
                    1997 (before they bundled IE3), Apple Safari, and the Lynx browser.

                    Mosaic seems to be the only one with sporadic support for the commonly found
                    short attributes (particularly select disabled). And I honestly only used
                    it myself a few times.

                    When I read W3Cs claim in the 4.01 specification, I tend to think they are
                    talking about some very arcane user agents. In 1999, there were only a few
                    real popular browsers (the wars were basically over), but other agent types
                    were emerging (such as the Libretto/CE handhelds, the Palm wannabes and PCS
                    telephones).


                    Anyways, I take back what I said. It is better worded as: Almost every
                    user agent since Netscape 3.2 has supported it.




                    usenet+2004@joh n.dunlop.name wrote:
                    >EVERY browser since Netscape 3.2 has supported it.
                    >
                    That's a big claim.
                    >
                    According to HTML4.01 (now 7 years old), 'many user agents only
                    recognize the minimized form of boolean attributes and not the full
                    form'.
                    >

                    Comment

                    • Jerry Stuckle

                      #11
                      Re: post of fetched value fails

                      Pedro Graca wrote:
                      rukkie wrote:
                      >
                      > <?php while($nt=mysql _fetch_array($r esult2)){
                      > echo "<option value=$nt[customer]>$nt[customer]</option>\n";}
                      >>?>
                      >
                      [...]
                      >
                      >>When I make a selection box, with fixed populated values (so values not
                      >>fetched from the db) then after the submission, I get the correct info
                      >>(values are not cutted to the first space).
                      >>
                      >>Is there anybody out there that can give a solution for this strange
                      >>(to me) behaviour ? It would be uttermost appreciated !
                      >
                      >
                      >
                      What's the difference between the PHP generated HTML and the one with
                      fixed populated values?
                      >
                      I'm guessing PHP does
                      >
                      <option value=John Smith>John Smith</option>
                      >
                      whereas the fixed value is
                      >
                      <option value="John Smith">John Smith</option>
                      >
                      Notice the quotes on the second line?
                      >
                      No, no difference at all, if it's coded correctly. If you view the
                      source in your browser, you should see:

                      <option value="John Smith">John Smith</option>

                      in either case.

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

                      Comment

                      • Pedro Graca

                        #12
                        Re: post of fetched value fails

                        Jerry Stuckle wrote:
                        Pedro Graca wrote:
                        >rukkie wrote:
                        >> echo "<option value=$nt[customer]>$nt[customer]</option>\n";}
                        // ----------------------------??-----------??
                        >I'm guessing PHP does
                        >>
                        > <option value=John Smith>John Smith</option>
                        No, no difference at all, if it's coded correctly.
                        Right! But the OP wasn't coded correctly.

                        --
                        File not found: (R)esume, (R)etry, (R)erun, (R)eturn, (R)eboot

                        Comment

                        Working...