Simple ColdFusion script works in IE, but not in Firefox?

I have a very simple script bit that changes the status of an item in the MySql database - it works fine in IE7, but if I try it in Firefox, it looks like it worked, but it doesn't exist ... This is very strange.

The code is very simple - first I get the details of the record I'm looking for:

<cfscript> // Get the Product Attribute details Arguments.qGetProductAttribute = Application.cfcProducts.getProductAttributes(Arguments.iProductAttributeID); </cfscript> 

This works fine if I give the result, it's just the contents of the record, as expected. Therefore, I use the if statement to change the "active" field from one to zero, or vice versa.

 <!--- If Product Attribute is active, mark as inactive ---> <cfif Arguments.qGetProductAttribute.bActive EQ 0> <cfquery name="qChangeStatus" datasource="#Request.sDSN#"> UPDATE tblProductAttributes SET bActive = <cfqueryparam value="1" cfsqltype="CF_SQL_INTEGER" maxlength="1" /> WHERE iProductAttributeID = <cfqueryparam value="#Arguments.iProductAttributeID#" cfsqltype="CF_SQL_INTEGER" />; </cfquery> <!--- Else if Product Attribute is inactive, mark as active ---> <cfelseif Arguments.qGetProductAttribute.bActive EQ 1> <cfquery name="qChangeStatus" datasource="#Request.sDSN#"> UPDATE tblProductAttributes SET bActive = <cfqueryparam value="0" cfsqltype="CF_SQL_INTEGER" maxlength="1" /> WHERE iProductAttributeID = <cfqueryparam value="#Arguments.iProductAttributeID#" cfsqltype="CF_SQL_INTEGER" />; </cfquery> </cfif> 

I see no reason this should not work ... and indeed, it works fine in IE7 ...

What happens after this script runs, the browser returns to the page on which all these entries are displayed. For each entry, if the "bActive" field is set to "1", it will display the word "Asset", and if it is set to "zero", it will display "Disabled". Simple enough.

If I run a script to turn off the record, Firefox actually displays the word “disconnected” as expected, but the database record does not change!

I’m at a loss ... how does the server code work fine in one browser and not in another ?!

+4
source share
6 answers

I found the cause of the problem ... Firebug.

I have no idea what Firebug thinks it is doing, if I remove the 'cflocation' tag from the script (the one that returns the user to the final page), then it works fine. But if I save it, Firebug seems to run the function again before redirecting the browser to the final page.

There is no reason for this. Un-damn-belivable.

At least this will not happen on customers' machines.

+3
source

Are you 100% sure that the database record has not changed? You can get this if firefox calls you script twice, once before rendering the page, and once after.

Thus, the product becomes disabled, and then after sending the page to the browser it is updated again (and since it is already disabled, it is turned on again).

If you added the latest update to the database and updated that every time your product is changed, you can find out if this is so.

EDIT: in response to the comments below, a quick + dirty fix will be to check the last update timestamp first, and if it is rejected within n seconds of the current time.

Do you have plugins in firefox that can rename a page? perhaps for dev purposes? a simple test to see if its script or quirk in firefox could change your url to get the form using the post method, since the browser / plugin should not re-request the submit request.

+3
source

This could be a browser caching issue. It is not possible to affect the direct CF code of the browser used. What happens if you refresh the page on which products are displayed? You also need to look at the database directly to see if the value is changing.

At a little tangent, you can eliminate the need for an if statement with a little simple math.

 <cfquery name="qChangeStatus" datasource="#Request.sDSN#"> UPDATE tblProductAttributes SET bActive = <cfqueryparam value="#val(1 - Arguments.qGetProductAttribute.bActive)#" cfsqltype="CF_SQL_INTEGER" maxlength="1" /> WHERE iProductAttributeID = <cfqueryparam value="#Arguments.iProductAttributeID#" cfsqltype="CF_SQL_INTEGER" />; </cfquery> 
+2
source

The code you posted is not the cause of the error, because it is all server-side code — nothing happens on the client there.

I would enable CF debugging (including database activity) and attach the tag immediately after the closing tag and before any redirect to the product view page. Run the code and look at the output of SQL debugging.

I assume that when using Firefox, the code block containing the requests is simply not called.

+2
source

Try removing the half colon at the end of the WHERE clauses in your SQL code.

 WHERE iProductAttributeID = <cfqueryparam value="#Arguments.iProductAttributeID#" cfsqltype="CF_SQL_INTEGER" />; 
0
source

all of these different answers, and none of them worked for me. I had to go to another forum where someone said that this is a Skype extension extension application in Firefox that causes ColdFusion databases to go crazy or not work. I uninstalled the Skype extension (thanks, Skype) and everything was fine. Hope this works for someone else as well.

0
source

Source: https://habr.com/ru/post/1277212/


All Articles