-> Data processing in IExplorer failing / Firefox ok: why? <-

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

    -> Data processing in IExplorer failing / Firefox ok: why? <-

    Hi,
    I have a strange behavior when using IExplorer over FireFox.

    There is an html form that asks for the name of a city and has
    a dedicated field for that with a submit button next to it.

    In IExplorer, if I hit return instead of clicking the button,
    the PHP query on MySQL fails when reaching the mysql_fetch_obj ect
    function. It's ok if I click the button.

    FireFox always works in both cases.

    I suspect that IExplorer interprets the return as a carriage return
    and inserts a control character in the query, whereas FireFox
    interprets the return as a click on the submit button.

    The PHP code seems ok. Here is the excerpt:

    <?php
    if( isset($_POST['submit'])) {
    $city= $_POST['city'];
    /* Connect to MySQL server and select database. */
    $linkID = @mysql_connect( "localhost","my user","mypasswo rd")
    or die("Could not connect to MySQL server");
    @mysql_select_d b("mydatabase ")
    or die("Could not select database");

    /* Create and execute query. */
    $query = "SELECT DISTINCT CS.recID, CS.COMM,
    CS.PROPRIETAIRE _DONNEE, CS.NO_REF,
    CS.GENRE, CS.ESPECE, CL.NomF
    FROM ChauvesSouris CS
    LEFT JOIN ChauvesLangages AS CL ON CS.GENRE = CL.GENRE
    AND CS.ESPECE = CL.ESPECE
    WHERE CS.COMM LIKE '$city%' ORDER BY CS.COMM ;" ;

    $result = mysql_query(str ip_tags(htmlspe cialchars($quer y)));
    }

    ?>

    <table cellspacing="2" cellpadding="1" border="0">
    <tr>
    <th class="id">ID</td>
    <th class="noref">N ° Ref</th>
    <th class="commune" >Commune</th>
    <th class="proprio" >Proprio</th>
    <th class="genre">G enre</th>
    <th class="espece"> Espèce</th>
    <th class="espece"> Nom</th>
    </tr>

    <?php
    while( $row = mysql_fetch_obj ect($result) ) {
    ... display code here
    }

    ---IExplorer crashes on this while line stating that:
    Warning: mysql_fetch_obj ect(): supplied argument is not a valid MySQL
    result resource in /home/www/apache/jorditests/thefile.php on line 38

    Any clue why???

    Thanks for any help

    Sincerely,
    Steve JORDI

    (Remove the K_I_L_LSPAM from my email address)
    ------------------------------------------------
    1197 Prangins Email: stevejordiK_I_L _LSPAM@hotmail. com
    Switzerland WWW: www.sjordi.com
    ------------------------------------------------
    Volcanoes at www.sjordi.com/volcanoes
    MovieDB at www.sjmoviedb.com
    ------------------------------------------------
  • Rik

    #2
    Re: -&gt; Data processing in IExplorer failing / Firefox ok: why? &lt;-

    Steve JORDI wrote:
    Hi,
    I have a strange behavior when using IExplorer over FireFox.
    >
    There is an html form that asks for the name of a city and has
    a dedicated field for that with a submit button next to it.
    >
    In IExplorer, if I hit return instead of clicking the button,
    the PHP query on MySQL fails when reaching the mysql_fetch_obj ect
    function. It's ok if I click the button.
    >
    FireFox always works in both cases.
    >
    I suspect that IExplorer interprets the return as a carriage return
    and inserts a control character in the query, whereas FireFox
    interprets the return as a click on the submit button.

    print_r($_POST) ; and you will probably see the difference.

    this line of code:
    if( isset($_POST['submit'])){

    }
    mysql_fetch_obj ect($result);
    Will give you the error in question: the query isn't run, but you still try
    to get it's results.

    The problem is FF indeed emulates the click on the first submit button it
    encounters (as it should, allthough I'm not really sure), while MSIE posts
    it without the 'submit' present.

    Solution:

    HTML:
    <input type="hidden" name="submitted " value="1" />

    PHP
    if( isset($_POST['submitted'])){
    //and ALL your database retrieval code here, not just the query
    }

    Grtz,
    --
    Rik Wasmus


    Comment

    • flamer die.spam@hotmail.com

      #3
      Re: -&gt; Data processing in IExplorer failing / Firefox ok: why? &lt;-


      Rik wrote:
      Steve JORDI wrote:
      Hi,
      I have a strange behavior when using IExplorer over FireFox.

      There is an html form that asks for the name of a city and has
      a dedicated field for that with a submit button next to it.

      In IExplorer, if I hit return instead of clicking the button,
      the PHP query on MySQL fails when reaching the mysql_fetch_obj ect
      function. It's ok if I click the button.

      FireFox always works in both cases.

      I suspect that IExplorer interprets the return as a carriage return
      and inserts a control character in the query, whereas FireFox
      interprets the return as a click on the submit button.
      >
      >
      print_r($_POST) ; and you will probably see the difference.
      >
      this line of code:
      if( isset($_POST['submit'])){
      >
      }
      mysql_fetch_obj ect($result);
      Will give you the error in question: the query isn't run, but you still try
      to get it's results.
      >
      The problem is FF indeed emulates the click on the first submit button it
      encounters (as it should, allthough I'm not really sure), while MSIE posts
      it without the 'submit' present.
      >
      Solution:
      >
      HTML:
      <input type="hidden" name="submitted " value="1" />
      >
      PHP
      if( isset($_POST['submitted'])){
      //and ALL your database retrieval code here, not just the query
      }
      >
      Grtz,
      --
      Rik Wasmus
      Yes thats correct, just to clarrify, when you hit enter in ie, it
      doesn't post submit, when you click the submit button it does. with ff
      it posts submit whether you click or hit enter. I believe this may be
      fixed in ie 6+

      Flamer.

      Comment

      • Rik

        #4
        Re: -&gt; Data processing in IExplorer failing / Firefox ok: why? &lt;-

        die.spam@hotmai l.com wrote:
        Rik wrote:
        >
        >Steve JORDI wrote:
        >>Hi,
        >>I have a strange behavior when using IExplorer over FireFox.
        >>>
        >>There is an html form that asks for the name of a city and has
        >>a dedicated field for that with a submit button next to it.
        >>>
        >>In IExplorer, if I hit return instead of clicking the button,
        >>the PHP query on MySQL fails when reaching the mysql_fetch_obj ect
        >>function. It's ok if I click the button.
        >>>
        >>FireFox always works in both cases.
        >>>
        >>I suspect that IExplorer interprets the return as a carriage return
        >>and inserts a control character in the query, whereas FireFox
        >>interprets the return as a click on the submit button.
        >>
        >>
        >print_r($_POST ); and you will probably see the difference.
        >>
        >this line of code:
        >if( isset($_POST['submit'])){
        >>
        >}
        >mysql_fetch_ob ject($result);
        >Will give you the error in question: the query isn't run, but you
        >still try to get it's results.
        >>
        >The problem is FF indeed emulates the click on the first submit
        >button it encounters (as it should, allthough I'm not really sure),
        >while MSIE posts it without the 'submit' present.
        >>
        >Solution:
        >>
        >HTML:
        ><input type="hidden" name="submitted " value="1" />
        >>
        >PHP
        >if( isset($_POST['submitted'])){
        >//and ALL your database retrieval code here, not just the query
        >}
        >>
        >Grtz,
        >--
        >Rik Wasmus
        >
        Yes thats correct, just to clarrify, when you hit enter in ie, it
        doesn't post submit, when you click the submit button it does. with ff
        it posts submit whether you click or hit enter. I believe this may be
        fixed in ie 6+
        Yup, found that out the hard way: items with a delete button next to it, and
        a submit button at the bottom to submit changes. Entering in FF would cause
        a virtual click on the nearest submit button. Imagine what happened...
        That's when I was glad the client had insisted there should be an 'are you
        sure?' form in between hitting delete and actually deleting :-)

        Grtz,
        --
        Rik Wasmus


        Comment

        • Steve JORDI

          #5
          Re: -&gt; Data processing in IExplorer failing / Firefox ok: why? &lt;-

          On 18 Jul 2006 15:24:24 -0700, "flamer die.spam@hotmai l.com"
          <die.spam@hotma il.comwrote:
          >Yes thats correct, just to clarrify, when you hit enter in ie, it
          >doesn't post submit, when you click the submit button it does. with ff
          >it posts submit whether you click or hit enter. I believe this may be
          >fixed in ie 6+
          Thanks for the clarifications.
          IE6 and IE7 behave the same way :-(

          But anyway, it's surprising it doesn't "post" so why, on the other
          hand, it moves to the file specified in the "action" parameter of
          the <postsection. It should not. It looks like IE is doing half
          of the post.

          Oh well.


          Sincerely,
          Steve JORDI

          (Remove the K_I_L_LSPAM from my email address)
          ------------------------------------------------
          1197 Prangins Email: stevejordiK_I_L _LSPAM@hotmail. com
          Switzerland WWW: www.sjordi.com
          ------------------------------------------------
          Volcanoes at www.sjordi.com/volcanoes
          MovieDB at www.sjmoviedb.com
          ------------------------------------------------

          Comment

          • Steve JORDI

            #6
            Re: -&gt; Data processing in IExplorer failing / Firefox ok: why? &lt;-

            Thanks,
            I moved around some of the code and initialized the $result
            variable and now it works fine.


            Sincerely,
            Steve JORDI

            (Remove the K_I_L_LSPAM from my email address)
            ------------------------------------------------
            1197 Prangins Email: stevejordiK_I_L _LSPAM@hotmail. com
            Switzerland WWW: www.sjordi.com
            ------------------------------------------------
            Volcanoes at www.sjordi.com/volcanoes
            MovieDB at www.sjmoviedb.com
            ------------------------------------------------

            Comment

            Working...