Connecting Tech Pros Worldwide Help | Site Map

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

Steve JORDI
Guest
 
Posts: n/a
#1: Jul 18 '06
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_object
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","myuser","mypassword")
or die("Could not connect to MySQL server");
@mysql_select_db("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(strip_tags(htmlspecialchars($query)));
}

?>

<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">Genre</th>
<th class="espece">Espèce</th>
<th class="espece">Nom</th>
</tr>

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

---IExplorer crashes on this while line stating that:
Warning: mysql_fetch_object(): 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
Guest
 
Posts: n/a
#2: Jul 18 '06

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


Steve JORDI wrote:
Quote:
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_object
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_object($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


flamer die.spam@hotmail.com
Guest
 
Posts: n/a
#3: Jul 18 '06

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



Rik wrote:
Quote:
Steve JORDI wrote:
Quote:
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_object
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_object($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.

Rik
Guest
 
Posts: n/a
#4: Jul 19 '06

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


die.spam@hotmail.com wrote:
Quote:
Rik wrote:
>
Quote:
>Steve JORDI wrote:
Quote:
>>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_object
>>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_object($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


Steve JORDI
Guest
 
Posts: n/a
#5: Jul 19 '06

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


On 18 Jul 2006 15:24:24 -0700, "flamer die.spam@hotmail.com"
<die.spam@hotmail.comwrote:
Quote:
>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
------------------------------------------------
Steve JORDI
Guest
 
Posts: n/a
#6: Jul 19 '06

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


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
------------------------------------------------
Closed Thread