By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,384 Members | 714 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,384 IT Pros & Developers. It's quick & easy.

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

P: n/a
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: st*******************@hotmail.com
Switzerland WWW: www.sjordi.com
------------------------------------------------
Volcanoes at www.sjordi.com/volcanoes
MovieDB at www.sjmoviedb.com
------------------------------------------------
Jul 18 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Rik
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_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
Jul 18 '06 #2

P: n/a

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_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.

Jul 18 '06 #3

P: n/a
Rik
di******@hotmail.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_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
Jul 18 '06 #4

P: n/a
On 18 Jul 2006 15:24:24 -0700, "flamer di******@hotmail.com"
<di******@hotmail.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: st*******************@hotmail.com
Switzerland WWW: www.sjordi.com
------------------------------------------------
Volcanoes at www.sjordi.com/volcanoes
MovieDB at www.sjmoviedb.com
------------------------------------------------
Jul 19 '06 #5

P: n/a
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: st*******************@hotmail.com
Switzerland WWW: www.sjordi.com
------------------------------------------------
Volcanoes at www.sjordi.com/volcanoes
MovieDB at www.sjmoviedb.com
------------------------------------------------
Jul 19 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.