CFLOCK

I just wanted to know when I need to use CFLOCK.

For example, should I CFLOCK when I give my data source database in my Application.cfc.

If I use CFLOCK web server locks the database for timeout seconds to connect to the database server?

Your information and your help is much appreciated,

Kind regards

Iccsi,

You need to lock when there will be a competitive situation, that's about it. http://en.Wikipedia.org/wiki/Race_condition#example

onApplicationStart() is simple threaded when she is called in the context of the application of the life cycle (http://adamcameroncoldfusion.blogspot.co.nz/2012/07/onapplicationstart-is-not-intrinsicall y.html), so there is no need to worry about locking scope application stuff in there.

--

Adam

Tags: ColdFusion

Similar Questions

  • CFLock and passing parameters

    Hello, I have two questions...

    Many examples of security of the site, I noticed the use CFlock tag. Hwoever, when you look at the documentation of CF9, in a specific example of the security of the site that includes user roles (using an application.cfc file) there is no mention of the herds. They are required to authenticate users or not? I don't see why they would. The variable being edited is the status of users (authenticated or not), and since it is in the session scope, it is already unique, no? So why bother with CFLock?

    Secondly, how can I redirect a person to the same page that they where after having submitted a form? I have a form letter of new present on all pages of the Web site, and I would like to than the person to return to the same page they where, the when they presented the form.

    In pre - mx days, i.e. ColdFusion 4.5, ColdFusion was leaking bad memory with the memory shared as session variables.  Popular workarounds should all reads and writes these variables.  That has long been useless, but there are always tons of old code examples and senior developers who continue to utilze this work around.

    The action of a form page is defined in the

    parameter.  If you name the form page itself as the action of the user page will remain on the same page.

    You can also name another page of the action, and then at the end of the processing of the page use a tag to redirect the user to the desired page.

  • CFLock identify anonymous locks and latches

    I'm new to CFLock, but have recently read on staves cflock and variable, etc. I feel that I have a solid understanding of the situation. In the documentation, I found this snipit I'm having problems understanding.

    "Lock scopes and names.
    The cflock tag prevented concurrent access to sections of the code, not variables. If you have two sections of the code that access the same variable, they must be synchronized to prevent them from running at the same time. This by identifying the locks with the same scope or name attributes.

    Note: ColdFusion does not require you to identify exclusive locks. If you omit the identifier, the lock is anonymous and you cannot synchronize the code in the tag cflock with another code block. Anonymous locks do not lead to errors when they protect a resource that is used in a single code block, but they are of bad programming practice. You must always identify read-only locks.
    "

    When they are referring to the anonymous locks, they suggest that you use the name option compared to the scope within the cflock tag option? See the examples below:

    < name cflock = "Logoutcount" type = "exclusive" timeout = "10" >
    < cfset application.logoutcount = application.logoutcount - 1 >
    < / cflock >

    OR

    < cflock scope = "Application" type = "exclusive" timeout = "10" >
    < cfset application.logoutcount = application.logoutcount - 1 >
    < / cflock >

    I guess that if the scope and / variable were the session level, I would just change the application to the session.

    What I'm trying to get clarification on here is as well, herds must be created using the name attribute or the scope attribute. I can't find much in the way of documentation pertaining to this matter.

    I think you're right. After I read your response, I re - read. I missed the sentence as follows "You do this by identifying the locks with the same scope or name attributes.".

    Thanks for pointing it out. Makes sense!

  • Why a feature of CFLOCK does not seem like a bug?


    I searched this forum for discussions about cflock
    and read the livedocs at http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=sharedVars_20.html.
    This reading is above me, thinking that I already knew
    all about using the cflock tag.

    Apparently, I'm not a very critical situation
    the appearance of the tag cflock when the scope of the session locking.

    My question is about a user, a single session, multiple
    and the simultaneous requests coming to the CF8 server
    the same session of the user.

    Sense, a web page that uses ajax, frameworks, pop-ups,
    or the user by pressing ctrl-n-va generate several
    requests to the server CF8 using the same session.

    Based on my understanding, using type = "exclusive will."
    effectively single-threaded access to the code between
    the label. So my question is:


    Why < cflock scope = "session" type = 'exclusive'... >
    single-threaded access to the code between the cflock
    Tag?


    If you are nice enough to answer, I would really
    explain why the current behavior
    in CF8 is the most correct behavior. If the scope
    past of the session of the application or server, it
    will be infact single-threaded execution access.
    Then why is it not the case when the scope is session?

    I came to this problem because I was trying
    to explain to someone the difference between:

    < cflock scope = "session" type = 'exclusive'... >
    and
    < cflock scope = "session" type = "readOnly"... >


    Based on my test simple and what I see, I discovered
    I don't know the difference!


    I know how to re - write the code to perform exactly
    what I want to do. I can't seem to wrap
    my head around why the cflock tag is implemented
    in this way (in which case the session and exclusivity).

    However, it is more likely that I have a bug in my
    simple test... code?

    If you are interested, here's the code I used to
    confirm/test my hypothesis:


    Thanks for reading this post to the end!

    Thank you all to consider this topic.

    Unfortunately the answer was because of my bad code.

    Tip and the Azadi persistence paid off.

    The question was NOT because of my tag
    having the REQUIRED 'NAME' attribute

    I have observed the behavior desired by
    just change my new code sample to include
    the name in my tag attribute.

    Thanks again to everyone who gave this post
    in-depth reflection.

    Moreover, in CF5, the name attribute is a required
    attribute. Post CF5 it is optional. After having
    through six different environments with six different
    configurations, I found a CD CF5 and installed.

    After removing the code java-ish, I quickly
    an error message indicating that the name attribute is a required
    attribute... Ouch.

    Perhaps one of the Adobe ColdFusion team
    can make a change that if the validator tag seen
    This line of code...

    the validator tag will throw an error indicating that
    the NAME attribute is missing.

    Maybe I titled this section as:

    Why a cfapplication feature does not seem like a bug?
    When sessionmanagement = true and the name of the attribute is missing

  • cflock timeouts

    When I lock a session against himself, I use something like:
    < name cflock = 'session #session. "CFToken #" type = exclusive timeout = 10 >
    [assume that one is logically equivalent to < cflock scope = session type = exclusive timeout = 10 >]

    So, assuming that a user is not access several pages at the same time (assuming that it takes less than 10 seconds per page) and this should never expire.

    However, sometimes, when I have a scheduled task running 10 to 20 user sessions timeout indicating that both the cflock is problem.

    Someone at - it ideas? The location of the error, it places won't there is a kind of uberlock being implicitly performed somewhere (given that the scheduled task does not have a cflock).
    Thank you!
    Tim

    It is possible that your original hypothesis that:

    «.. . a user access to multiple pages simultaneously.

    is incorrect? I could imagine a scenario where a user accesses a lock called "session #session. CFToken # ", which makes a long slow call to the database. If this user gets tired of waiting and strikes, stop and refresh in the browser, it is possible that their original request thread is being processed, and the second request thread that uses the name lock once again 'session #session. CFToken # ", wait more than 10 seconds for the first lock to"liberate"and then raise an error.

    Is there a way that you can dig into the web server logs to see if this is indeed the behavior that takes place at the time that these lock deliver timeout errors?

  • Component in the scope and cflock

    Hello

    I have a CFC that I put in the scope in the SystemFramework method that contains some system settings, which is an indicator to tell if the site is currently 'online '. I call a method on this CFC in the 'onRequest' Application.cfc method to see if the value of the indicator has changed.

    This method throws a parameter defined in the database that indicates whether the site is "online" or "offline". If the site is currently online, I want to just redo the query every 5 minutes. However, if the site is unavailable, I want to check more frequently (every 5 seconds) as to if the flag changed back.

    I don't know, what if I need to use < cflock > when I change from 'online' to 'offline '? There is only one instance of this object, but what happens if several applications are calling the 'isSiteOnline' method at the same time? It is "safe"?

    Some code snippets are attached to illustrate.

    Any advice would be greatly appreciated.

    Kind regards
    Andrew.

    >

    No, in every situation.

    Ask yourself... The consequences of two queries hit
    This line of code "simultaneously"? The final result is that both of them
    are setting the variable to the same static value... it's what's happening
    eventually occur: variables.instance.cacheInterval will be the value
    300 (or 5) in each situation.

    You may with to lock a block of code which - if called
    at the same time through several applications - could act on shared storage
    space (server, application or session data) differently and incorrectly
    What is planned.

    for example:


    application.isInitialised >






    So a sequence of events might be (for example, the user is hitting the site with two
    different browsers):

    REQUEST1: application.isInitialised does not exist
    REQUEST1: starts the init process
    REQUEST2: application.isInitialised STILL does not exist
    REQUEST2: starts the init process * new *.
    REQUEST1: sets the value of application.isInitialised
    REQUEST2: sets the value of application.isInitialised

    Of course, we don't want two ask the running initialization code.

    Note This is an example a bit far-fetched, as if we have a
    OnApplicationStart() method, then it runs only once, and that's where
    Should the init code, but it illustrates the problem.

    Google "race condition". These are the situations in which there
    the code lock blocks.

    --
    Adam

  • Why do I get a SQL syntax; consult the manual for your version of the MySQL server for the proper syntax

    I have a purchase order where my buyers can add to my form. I use a loop that adds an extra line when they add a new product. I'm storing the information in two tables different mySQL. The first is alll of my personal, the second is the elements. My personal records correctly. However, I get the following error when you save the items:

    You have an error in your SQL syntax; consult the manual for your version of the MySQL server for the right syntax to use near 1, 'wer 2345', 1, 1)' on line 9

    The error occurred in E:\webs\clarkwebhosting.com\SSL\esrc\order_add.cfm on line 74

    ++ After storage of the personal information, I take the command ID to populate the table of Articles

    < cflock timeout = "5" >

    < name cfquery = "qGetorderID" datasource = "#application.dsn #" >

    Select max (orderID) as oid of orders

    < / cfquery >

    < / cflock >

    < cfoutput > < cfset getoid = #qGetorderID.oid # > < / cfoutput >

    ++ Is the loop that I use to fill the table items ++

    < cfloop to = "#form.numba # '1' = ' index 'idx' = >"

    < cfset getqty = evaluate ("form.qty" & idx) >

    < cfset getitem = evaluate ("form.item" & idx) >

    < cfset getunit = evaluate ("form.unit" & idx) >

    < cfset gettotal = evaluate ("form.total" & idx) >

    < name cfquery = "insertItems" datasource = "#application.dsn #" >

    INSERT in Articles

    (orderID,

    quantity,

    agenda,

    Unit,

    total

    )

    VALUES)

    < cfqueryparam value = "" #getoid # "CFSQLType ="CF_SQL_INTEGER">"

    < cfqueryparam value = "" #getqty # "CFSQLType ="CF_SQL_INTEGER">,"

    < cfqueryparam value = "" #getitem # "CFSQLType ="CF_SQL_VARCHAR">,"

    < cfqueryparam value = "" #getunit # "CFSQLType ="CF_SQL_INTEGER">,"

    < cfqueryparam value = "" #gettotal # "CFSQLType ="CF_SQL_INTEGER">"

    )

    < / cfquery >

    < / cfloop >

    This line: 1, 'wer' 2345, 1, 1 is the first element of the command line. Any ideas as to why it doesn't work? I use 5.5.9 - log CF9 and mySQL

    My apologies... that should have been (note the quotes)...

    In addition, it would be...

    On another note... You should probably avoid using cfinput and simply use the standard form tags.

  • How to stop double click on registration in a SQL update

    I have a banner server where an end user clicks on a banner, the link goes to my CLK redirection script. CFM, this page records the clicks in the SQL dbase and then there a CFLOCATION to redirect the user to the appropriate web site.

    The problem I see is that when there is a delay between the 3rd party site that the end user is clicking several times and it's actually recording several clicks in the database

    I tried to write a simple code where the page that displays the banner sets a = session.click "1 session variable", and then when they hit the CLK page I check the value of session.click, if it is empty I have not update SQL, just go directly to the CFLOCATION, but if there is a value of 1 update the database and then I put session.click vacuum " , so in theory a single click should never record, but even with the longer time the CFLOCATION will always do its thing.

    Yet after all that, I still see multiple clicks, and the timestamp shows they occur less than one second or or less than the other, then this is definitely a press several.

    Anyone has an idea why my approach above may not work, and what can I do to stop this?

    Thank you

    Mark

    ACS LLC wrote:

    I have it.

    I actually put it on the CFM page that pulled into the model so that the entire page was covered, not sure if that causes any problems, but so far it seems actually to have done the trick! I keep an close eye on it

    So basically all that changes the session.click anyway, I should have the lock autour. I had also cflock was part of the page, that aside the last command to the click CLK CFLOCATION.

    I'll give it 24 hours and see if it pans, and if so maybe I'll try the less CFLOCK d code to see if it still work

    Nice to hear he has so far. I experiment with some quickfire double and triple clicking. Good luck.

  • Does not Abend when row not found for update?

    I use Coldfusion 9 against a DB2 from IBM mainframe database.  I have a condition that when a line is not found for update in a cfquery, run a cfquery insert.  Sounds logical and easy, right?  Not the case!  Error recovery fails to return an error condition when the line was not found for the update!

    Here is the code:

    < cftry >

    < cfinclude template = "qry_update_table.cfm" >

    < cfcatch type = "any" >

    < cfinclude template = "dsp_errorInformation.cfm" >

    < cfabort >

    < / cfcatch >

    < / cftry >

    < cfdump var = #tmec04_result # > < cfabort >

    Request code is:

    < cflock timeout = "15" name = "UpdateTUID04Lock" type = "exclusive" >

    < cfquery datasource = '#APPLICATION. "DB2_DSN #" name = "update_tuid04" result = "tmec04_result" >

    UPDATE #APPLICATION. SQLID #. TUID04

    SET MON_BEG_TIME = < cfqueryparam value = #NEW_MON_BEG # cfsqltype = "cf_sql_time" >

    MON_END_TIME = < cfqueryparam value = #NEW_MON_END # cfsqltype = "cf_sql_time" >

    WHERE USER_ID = < cfqueryparam value = #NEW_USER_ID # cfsqltype = "cf_sql_varchar" >

    < / cfquery >

    < / cflock >

    There is no line for the NEW_USER_ID, so I'm expecting an error condition.  No luck.  The discharge of temc04_result comes from shows me the SQL, the number of records (0), runtime (0) and the State of caching (false).  No SQL code.  And a dump CFCATCH shows that everything is fine.  I expected to get cfcatch.nativeerrorcode = 100 (found online).  Nope.  Got a zero.

    All of the suggestions.

    With regard to this:

    There is no line for the NEW_USER_ID, so I'm expecting an error condition.

    Your wait is incorrect.  What actually happens is that the query is running and updated no line.

    What is to happen, it is to see if the file is there and if not, insert it.  There are many ways to do it.  I think the simplest is a query of insertion,

    insert into yourtable

    (Field1, Field2, etc.)

    Select distinct value1, value2, etc.

    a small table

    where there is not (something)

    Following up the update request.

  • being lost ColdFusion session variables

    Okay, so when my users login I create session variables. one of them is the employee id. in my Application.cfc I have this at the top:

    < cfscript >
    myIdName = "My App";
    This.SessionTimeout = CreateTimeSpan ("0", "0", "45", "0");
    This. SESSIONMANAGEMENT = "YES";
    This. SetClientCookies = "true";
    this.setDomainCookies = "true";
    < / cfscript >

    I also put the timeout for sessions at 45 in the CFadmin too.

    After a successful login, I capture their session.employeenumber by is authenticating through our enterprise LDAP. no problem. Note: this app has run smoothly for 6 years now but recently something has gone wrong.

    on every page I reference a file in my application directory called "check_session.cfm" like this:

    "< cfmodule template="/myApp/Tags/check_session.cfm ">

    In this file, I have the code that verifies the existence of the session.employee_number. If there is no they expired or book marked a page in the application in which they need to be logged in to view:

    < cflock timeout = "30" throwontimeout = "Yes" type is 'READONLY' scope is "SESSION" >
    <! - checks to ensure that the user has a session - >
    < CFIF NOT IsDefined ("Session.employee_number") >
    "< CFLOCATION URL ="http://#cgi.HTTP_HOST#/myApp/LoginAgain.cfm">."
    < / CFIF >
    < / cflock >

    time to time (I would say on average 5 times a week) I get a message to a user error (I redirect errors to my email with information on the diagnosis). the error reads "EMPLOYEE_NUMBER element is not defined in the SESSION". when I look at the page the error came I see my call to the file check_session.cfm about 50 lines above where this error occurred when I tried to reference session.employee_number. Why wouldn't he not find it and redirect the user to the page timeout? I can't reproduce this error on my machine... I always get the good result without the error message. It's a random, sporadic, intermittent error.

    A long time ago (but in this Galaxy) we found isDefined() can give false positives with session variables, exactly the way you describe.  Or indeed something as simple as this could mistake with "session.foo does not exist" on line 2 (ie: the line inside the if() function.)

    If (isDefined ("session.foo")) {}

    something = session.foo.

    }

    And the session variable absolutely did NOT exist (or a similar variable was in none of the controls isDefined() extended, for example: variables.session.foo).  If the error was right... but the isDefined() call did not work.

    The problem was occasional, so hard to follow.

    We changed the calls to structKeyExists() and the problem disappeared.

    It was in CFMX7 well, and we had not never really much time investigating her in addition, after that we have treated the symptom.  However, I have been conscious of others with similar experiences.

    However we have stopped using isDefined() right there (for all) and has never ever had similar problems.

    Maybe try it.

    --

    Adam

  • Create a link using dynamic text and Capture of Variable

    I'm building a dynamic website with Dreamweaver CS5 with Coldfusion 9

    Currently, I created an array of dynamic text. The table is created by querying the invoice table and displays all of the invoices customers. The columns Include invoice #, Date, amount paid, BalanceRemaining, Expiration Date. So, basically lists all invoices that I made a request to the unique customer. It is pulled up using a session variable, that I created from the login page.

    My question is I want to do the # "Bill" when you click on it it goes to a new page and executes a query that retrieves infro associated with this specific invoice such as Services rendered, the Description of Service, Date, price, Total. I was able to create a link to the invoice # but I'm stuck trying to figure out how to capture the Unique invoice # and apply it to the new query. Is it possible if yes, how?

    Thanks for your help!

    < cflock scope = "Session" type = "ReadOnly" timeout = "30" throwontimeout = "no" >

    < cfset MM_Username = Iif (IsDefined("Session.MM_Username"), "Session.MM_Username", DE("")) >

    < cfset MM_UserAuthorization = Iif (IsDefined ("Session.MM_UserAuthorization"), "Session.MM_UserAuthor-ization", DE("")) >

    < / cflock >

    < cfif MM_Username EQ "" EQ MM_UserAuthorization or "" or ListFind("User,Admin",MM_UserAuthorization) EQ 0 >

    < cfset MM_referer = CGI. SCRIPT_NAME >

    < cfif CGI. QUERY_STRING NEQ "" > "".

    < cfset MM_referer = MM_referer & "?" & CGI. QUERY_STRING >

    < / cfif >

    < cfset MM_failureURL = "" sorry.cfm? accessdenied = "and URLEncodedFormat (MM_referer) >"

    < cflocation url = "' #MM_failureURL # ' addtoken ="no">"

    < / cfif >

    < cfparam name = default "PageNum_Invoice" = "1" >

    < cfset GetFileFromPath = CurrentPage (GetBaseTemplatePath ()) >

    < cfparam name = default "PageNum_Query_Invoice" = "1" >

    < cfquery name = "Query_Invoice" datasource = "SBC" >

    SELECT DueDate, AppliedAmount, RefNumber, BalanceRemaining, TxnDate

    OF the invoice

    WHERE CustomerRefFullName = < cfoutput > ' #Session.FullName # ' < / cfoutput >

    < / cfquery >

    < cfset MaxRows_Query_Invoice = 10 >

    < cfset StartRow_Query_Invoice = Min ((PageNum_Query_Invoice-1) * MaxRows_Query_Invoice + 1, Max (voice of Query_In.) RecordCount, 1)) >

    < cfset EndRow_Query_Invoice = Min (StartRow_Query_Invoice + MaxRows_Query_Invoice-1, Query_Invoice.Rec ordCount) >

    < cfset TotalPages_Query_Invoice = Ceiling(Query_Invoice.RecordCount/MaxRows_Query_Invoice) >

    < cflock scope = "Session" timeout = "30" type = "Exclusive" >

    <! - Session variable for invoice reference number - >

    < cfset Session.RefNumber = Query_Invoice.RefNumber [1] >

    < / cflock >

    < cfset QueryString_Query_Invoice = Iif (CGI. QUERY_STRING NEQ "", FROM ('&' & XMLFormat (CGI.) (QUERY_STRING)), de("")) >

    < cfset tempPos = ListContainsNoCase (QueryString_Query_Invoice, "PageNum_Query_Invoice =", "&") >

    < cfif tempPos NEQ 0 >

    < cfset QueryString_Query_Invoice = ListDeleteAt (QueryString_Query_Invoice, tempPos, "&") >

    < / cfif >

    < ! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional / / IN" "http://www.w3.org/TR/html4/loose.dtd" > ""

    "< html > <!-InstanceBegin template="/Templates/customer_template.dwt.cfm ' codeOutsideHTMLIsLocked = 'false'->

    < head >

    < meta http-equiv = "Content-Type" content = text/html"; charset = utf-8 ">"

    <!-InstanceBeginEditable name = "title"--> < title > Untitled Document < / title > <! - InstanceEndEditable - >

    < link href = "styles/Main.css' rel ="stylesheet"type =" text/css">"

    < script src = "SpryAssets/SpryMenuBar.js" type = "text/javascript" > < / script > "

    < link href = "SpryAssets/SpryMenuBarHorizontal.css" rel = "stylesheet" type = "text/css" > "

    <!-InstanceBeginEditable name = 'head'-> head content goes here <! - InstanceEndEditable - > < / head >

    < body >

    < div id = "Container" >

    < div id = "header" > < img src = "Images/site Web - Image.gif" width = "393" height = "217" alt = "TS planning landscaping Logo and company name" > < / div >

    < div id = "menu_bar1" >

    < ul id = "MenuBar1" class = "MenuBarHorizontal" >

    < li > < a class = "MenuBarItemSubmenu" href = "index.cfm" > home < /a >

    < ul >

    < li > < a href = "#" > 1.1 < /a > < /li >

    < li > < a href = "#" > 1.2 < /a > < /li >

    < li > < a href = "#" > question 1.3 < /a > < /li >

    < /ul >

    < /li >

    < li > < a href = "#" > about us < /a > < /li >

    < li > < a href = "#" > Services < /a > < /li >

    < li > < a class = "MenuBarItemSubmenu" href = "#" > user account < /a >

    < ul >

    < li > < a href = "login.cfm" > Connect < /a > < /li >

    < li > < a href = "registration_page_contact.cfm" > register < /a > < /li > "

    < li > < a href = "members_page.cfm" > customer Page < /a > < /li > ""

    < /ul >

    < /li >

    < li > < a href = "#" > contact us < /a > < /li >

    < /ul >

    < / div >

    < div id = 'Hand' >

    < div id = "side_bar" > <!-InstanceBeginEditable name = "sidebar"-> content for id "side_bar" goes here <! - InstanceEndEditable - > < / div >

    < div id = "main_body" > <!-InstanceBeginEditable name = "mainbody"->

    < H1 > < cfoutput > #Session.FullName # < / cfoutput > bills < / h1 >

    < p > here you can view your bills current and past. < /p > < br >

    < name of the form = "customerinvoices" >

    < table border = "1" align = "center" >

    < b >

    < td > < div align = "center" > invoice # < / div > < table >

    < td > < div align = "center" > Date < / div > < table >

    paid < td > < div align = "center" > < / div > < table >

    < td > < div align = "center" > BalanceRemaining < / div > < table >

    Due Date < td > < div align = "center" > < / div > < table >

    < /tr >

    < cfoutput query = "Query_Invoice" StartRowOptional = "" #StartRow_Query_Invoice # "LignesMax =" #MaxRows_Query_Invoice #">"

    < b >

    < td > < a href = "invoice_number_page.cfm" > #Query_Invoice.RefNumber # < /a > < table >

    < td > #LSDateFormat (Query_Invoice.TxnDate, 'MMMM DD, YYYY') # < table >

    < td > #DollarFormat (Query_Invoice.AppliedAmount) # < table >

    < td > #DollarFormat (Query_Invoice.BalanceRemaining) # < table >

    < td > #LSDateFormat (Query_Invoice.DueDate, "MMMM DD, YYY'") # < table >

    < /tr >

    < / cfoutput >

    < / table > < / make >

    < p > < table border = "0" align = "center" >

    < cfoutput >

    < b >

    < td > < cfif PageNum_Query_Invoice GT 1 >

    < a href = "#CurrentPage #?" PageNum_Query_Invoice = 1 #QueryString_Query_Invoice #"> first < /a >"

    < cfelse > sorry no bills have been found!

    < / cfif > < table >

    < td > < cfif PageNum_Query_Invoice GT 1 >

    < a href = "#CurrentPage #?" PageNum_Query_Invoice = #Max (DecrementValue (PageNum_Query_Invoice), 1) # QueryString_Query_Invoice #"> back < /a >"

    < / cfif > < table >

    < td > < cfif PageNum_Query_Invoice LT TotalPages_Query_Invoice >

    < a href = "#CurrentPage #?" "PageNum_Query_Invoice = #Min (IncrementValue (PageNum_Query_Invoice), Tota lPages_Query_Invoice) # QueryString_Query_Invoice # ' > next < /a >

    < / cfif > < table >

    < td > < cfif PageNum_Query_Invoice LT TotalPages_Query_Invoice >

    < a href = "#CurrentPage #?" PageNum_Query_Invoice = #TotalPages_Query_Invoice # QueryString_Query_In voice #"> last < /a >"

    < / cfif > < table >

    < /tr >

    < / cfoutput >

    < table / > < / p >

    <! - InstanceEndEditable - > < / div >

    < / div >

    < div id = "footer" >

    < p > home | Who are we | < /P > site map

    < p > & copy; TS in planning landscaping LLC 2010 < /p >

    < / div >

    < / div >

    < script type = "text/javascript" >

    var MenuBar1 = new Spry.Widget.MenuBar ("MenuBar1", {imgDown: "..."}) "" / SpryAssets/SpryMenuBarDownHover.gif ', imgRight: ".. ({"/ SpryAssets/SpryMenuBarRightHover.gif"});

    < /script >

    < / body >

    <! - InstanceEnd - > < / html >

    Without trying to sift through all the code has nothing to do with the question, I think you want to do something like this:

    Select number, Word

    etc.

    #word #.

    Then on nextpage.cfm, your variable will be url.thenumber.

  • Create Unique Session Variable based on the login page

    Hello:

    I'm building a dynamic website with Dreamweaver CS5 with Coldfusion 9.

    My question is how can I set a session variable to read a certain value. It is currently when my clients go to the login page they enter their username and password. I was able to create a session variable that contains the user name as value. So in all their pages read Welcome website "all that was their connection username. Now, I want to get the session variable to read the same table but the different FullName field. This way, that the web pages will say Welcome "FullName (based on their login user name)" I tell myself that I have to configure a query parameter, but after trying and failing for four hours to produce a successful result, I resorted to post my problem here. I appreciate the help and advice.

    My information:

    DataSource = Table 'Access' = 'Logininfo' (current) land (for the session variable) = 'User_name' (desired) field (for the session variable) = "full name".

    Currently using (server behaviors: Variable de Session) MM_Username on each relevant page for the user.

    My sign in page code is as follows:

    Head:

    < IsDefined ("FORM.username") cfif >

    < cfset MM_redirectLoginSuccess = "members_page.cfm" >

    < cfset MM_redirectLoginFailed = "sorry.cfm" >

    < "MM_rsUser" datasource = cfquery name = "Access" >

    "SELECT AccessLevels FROM Logininfo WHERE username, password, username, FullName is < cfqueryparam value =" "#FORM.username #" cfsqltype = "cf_sql_clob" maxlength = "50" > AND password = < cfqueryparam value = "#FORM.password #" cfsqltype = "cf_sql_clob" maxlength = "50" >

    < / cfquery >

    < cfif MM_rsUser.RecordCount NEQ 0 >

    < cftry >

    < cflock scope = "Session" timeout = "30" type = "Exclusive" >

    < cfset Session.MM_Username = FORM.username >

    < cfset Session.MM_UserAuthorization = MM_rsUser.AccessLevels [1] >

    < / cflock >

    < cfif IsDefined ("URL.accessdenied") AND false >

    < cfset MM_redirectLoginSuccess = URL.accessdenied >

    < / cfif >

    < cflocation url = "' #MM_redirectLoginSuccess # ' addtoken ="no">"

    < cfcatch type = 'Lock' >

    <! - the timeout of cflock management code - >

    < / cfcatch >

    < / cftry >

    < / cfif >

    < cflocation url = "' #MM_redirectLoginFailed # ' addtoken ="no">"

    < cfelse >

    < cfset MM_LoginAction = CGI. SCRIPT_NAME >

    < cfif CGI. QUERY_STRING NEQ "" > "".

    < cfset MM_LoginAction = MM_LoginAction & "?" & XMLFormat (CGI. QUERY_STRING) >

    < / cfif >

    < / cfif >

    Body:

    Connection < h1 > < / h1 >

    < p > please enter your login information the registration form in order to access your member account page. < /p >

    < form ACTION = "" < cfoutput > #MM_loginAction # < / cfoutput > "method ="POST"id ="login"> < table width ="auto"border ="0"align ="center">"

    < b >

    < td > < label for = "username3" >

    < div align = "right" > user name: < / div >

    < / label > < table >

    < td > < span id = "sprytextfield1" >

    < input type = "text" name = "user name" id = "NomUtilisateur2" accesskey = "n" tabindex = "10" >

    < span class = "textfieldRequiredMsg" > a value is required. </span > < / span > < table >

    < /tr >

    < b >

    < td > < label for = "password" >

    < div align = "right" > password: < / div >

    < / label > < table >

    < td > < span id = "sprypassword1" >

    < input type = "password" name = "password" id = "password" accesskey = "n" tabindex = "15" >

    < span class = "passwordRequiredMsg" > a value is required. </span > < / span > < table >

    < /tr >

    < b >

    < td colspan = "2" > < div align = "center" >

    < input type = "submit" name = "submit" id = "submit" value = "Login" accesskey = "n" tabindex = "20" >

    < / div > < table >

    < /tr >

    < /table >

    < / make >

    < script type = "text/javascript" >

    var sprytextfield1 = new Spry.Widget.ValidationTextField ("sprytextfield1");

    var sprypassword1 = new Spry.Widget.ValidationPassword ("sprypassword1");

    < /script >

    I'm sure it is something simple and will show my status as a rookie for the asking, but thanks for your help!

    A session variable is also the best route to go? I'll use this to query databases to display and allow them to change contact information, also show their invoices and request services.

    I don't know CF so forgive me, but you can create a session for fullname variable or use a query on your pages to filter the data WHERE username = user session variable. Looking at your code, it looks like you can add a session to the full name variable here:

  • Array of names of col cfquery

    Hi peeps - you have a little tedious problem.

    I am running a cfquery on a database of recovery of the column names are stored in a table.

    The cfquery works very well, and I can't cfdump of data with no proolem at all, however once I try to put out inside a cfoutput, instead of the value of the fields, the output displays the names of the fields. I think it's because I nested a cfloop to inside the thew cfoutput tag field names:

    < cfoutput query = "qGet_cust" >
    < b >
    < td > #MID (LEGAL_ENTITY_CODE, 2, 10) # < table >
    < cflock scope = "session" throwontimeout = "Yes" type = "readonly" timeout = "10" >
    < cfloop FROM '1' TO = = "#ArrayLen (SESSION.parameter_array)" # "index =" LOCAL.this_var ">"
    < cfset LOCAL.this_column = ". qGet_cust" & "#SESSION.parameter_array [LOCAL.this_var] [1] # ' >
    #LOCAL.this_column # < td > < table >
    < / cfloop >
    < / cflock >
    < /tr >
    < / cfoutput >

    The first column is the LEGAL_ENTITY_CODE domain name, and that copies the data from the cell without problem. However, the following cells show that the name of the column, rather than the content

    Header 1 Header 2 Header 3
    Legal person

    Current year of Internet access
    Calls and lines the current year
    0003272773qGet_cust. INTERNET_ACCESS_cyrqGet_cust. CALLS_AND_LINES_cyr
    0002808637qGet_cust. INTERNET_ACCESS_cyrqGet_cust. CALLS_AND_LINES_cyr
    0001464359qGet_cust. INTERNET_ACCESS_cyrqGet_cust. CALLS_AND_LINES_cyr


    How can I get the code to multiply the contents of the request, rather than the column names? I am running CF MX7. Thank you.

    But the first example, #qGet_cust [SESSION.parameter_array [LOCAL.this_var]] [1] # if it is to launch this error, which simply means that I didn't put in the correct, complete structure that contains the column names in the first query [row] [column] structure brackes.

    Altogether.  From the original code, this is the correct name:

    IE: the column name is ' #SESSION.parameter_array [LOCAL.this_var] [1] #

    If the correct query [column] [row] representation of this would be:

    qGet_cust [SESSION.parameter_array [LOCAL.this_var] [1]] [qGet_cust.currentRow]

    Ian used [1] of the ref column name as a line (by accident) ref.

    --

    Adam

  • Newbie? on the variables

    I'm completely ignorant about CF, besides I'm generally ignorant as well. I am the owner of a website written in CF that I need to change. I change the URL to the site and need to update the links within the site to reflect the changes. Most of the links contain a variable that would make it easy but... I don't know where the variable is defined. I pasted a sample page of code below:

    < cfinclude template = "urlhelp.cfm" >

    < cflock scope = "application" type = "exclusive" timeout = "30" > < cfset variables.homepage = Home Page > < / cflock >

    < name cfparam = default "title_tag" = "lifestyles Direct Tan through Suits" >

    < name cfparam = 'meta_description' default = 'Lifestyles direct Tan through swimwear allows you to achieve the perfect tan all over. Our fashionable line of the swimwear of swimwear for men and women is guaranteed be tan, but not see through the wet or dry! ">

    <! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional / / IN".

    " http://www.w3.org/TR/html4/loose.DTD ">

    < html >

    < head >

    < meta http-equiv = "Content-Type" content = text/html"; charset = iso-8859-1 ">"

    < name meta = "description" content = "< cfoutput > #meta_description # < / cfoutput >" >

    < title > < cfoutput > #title_tag # < / cfoutput > < / title >

    < / head >

    < link href = "" < cfoutput > #homepage # < / cfoutput > / solartan.css "rel ="stylesheet"type =" text/css">"

    < body leftmargin = "0" topmargin = "0" marginWidth = "0" marginheight = "0" >

    < table width = "100%" border = "0" cellspacing = "0" cellpadding = "0" >

    < tr >

    < td > < table width = "100%" border = "0" cellpadding = "0" cellspacing = "0" background = "< cfoutput > #homepage # < / cfoutput > / images/beach_bkg.jpg" >

    I see in line 2, the reference to variables.homepage = Homepage but do not understand how that defines something. I also see where the variable is called in the last line I posted as: background = "" < cfoutput > #homepage # < / cfoutput > / images/beach_bkg.jpg ' "

    If you need more information, I will do my best to give it. Thanks in advance for any help!

    In the first opinion, I have to say that I don't see much use for this variable.  It is used to build a base of links and others, url that does not make much sense but the value is defined in the page itself.

    But other places that you should look to get a more complete picture what is happening.  That should make the file urlhelp.cfm.  The file name makes it sound like it might be relevant to this topic.

    There is also the default include files, Application.cfm *OR* Applicaiton.cfc depending on the age of your application.

  • Weird error message "undefined format": but defined - someone ' can someone help?

    Here is the < form > code:

    <!--list generated dynamically bowling center names-->

    < cfselect class = "selectBox" name = "regHomeCntr" >

    < option selected = "selected" > where is your Center bowling House? < / option >

    < cfloop query = "getBowlCenters" >

    < option value = "#getBowlCenters.ctrName #" > #getBowlCenters.ctrName # < / option >

    < / cfloop >

    the < cfform > passes information above for model (below) for insertion into DB. EVeRyThiNg successfully treats (as shown in the table at the top of the web page variable). Even the name of the bowling center is passed as a variable to the processing page, but CF always tells me that the variable is not set, but I see that he spent the variable to the next page. I thought it was because I had the wrong < CFSELECT >, but no matter what is selected, the variable is passed. I'm puzzled.

    The following code hangs:

    < name cfquery = "getTournaments" datasource = "#dbs #" >

    SELECT *.

    OF tournamentFeatures

    WHERE tName = ' #URL.tName # '.

    < / cfquery >

    < table >

    < b >

    < td > < strong Variable name > < / strong > < table >

    < td > < value > < / strong > < table >

    < /tr >

    <!-loops on the URL structure and displays the names of variables and values->

    < cfloop collection = "" #URL # "item ="Nomvar">"

    < cfoutput >

    < b >

    < td >

    #VarName # < table >

    < Td > #URL [VariableName] # < table >

    < /tr >

    < / cfoutput >

    < / cfloop >

    < /table >

    < p > < / p >

    < table >

    < b >

    < td > < strong Variable name > < / strong > < table >

    < td > < value > < / strong > < table >

    < /tr >

    <!-loops on the FORM, structure and displays the names of variables and values->

    < cfloop collection = "" # form # "item ="Nomvar">"

    < cfoutput >

    < b >

    < td >

    #VarName # < table >

    < td > #form [VariableName] # < table >

    < /tr >

    < / cfoutput >

    < / cfloop >

    < /table >

    <! - inserts the new tournament entry in the registration table - >

    < name cflock = "addRegistrationRecord" type = "exclusive" timeout = "20" >

    < cftransaction >

    < name cfquery = "insertRegistration" datasource = "RBDS" >

    INSERT INTO

    tournamentReg

    SET

    tNom = #URL.tName #,.

    adate = ' #URL.tDate # '.

    regDateTime = ' #URL.regDateTime # ',.

    regNumber = ' #URL.regNumber # '.

    regFName = ' #form.regFName # ',.

    regLName = ' #form.regLName # ',.

    streetAddr = ' #form.streetAddr # ',.

    cityStateZip = ' #form. CityStateZip #',

    regPhone = ' #form.regPhone # ',.

    regEmail = ' #form.regEmail # ',.

    lastBook = ' #form.lastBook # ',.

    usbcCard = ' #form.usbcCard # ',.

    < cfif tNom EQ #URL.tname # 'double' AND IS 'Yes' >

    bowlWith2 = ' #form.bowlWith2 # ',.

    < cfelseif tNom EQ #URL.tname # AND 'threePerTeam', it is 'Yes' >

    bowlWith3 = ' #form.bowlWith3 # ',.

    < cfelseif tNom EQ #URL.tname # AND 'fourPerTeam', it IS 'Yes' >

    bowlWith4 = ' #form.bowlWith4 # ',.

    < cfelseif tNom EQ #URL.tname # AND 'fivePerTeam', it IS 'Yes' >

    bowlWith5 = ' #form.bowlWith5 # ',.

    < cfelse >

    singlesTournament = ' #form.singlesTournament # '.

    < / cfif >

    regHomeCntr = ' #form.ctrName # ' (PLANT HERE)

    tNom = ' #URL.tName # ' AND tDate = ' #URL.tDate # '.

    < / cfquery >

    Try the code yourself on an online site to see what I mean.

    First of all, go: http://www.renobowls.com/tournaments.cfm, then click on the button to the right of the Test 2. You do not have to fill in the text boxes, but one of the Bowling centers select in the drop-down list. Then click on ' to register me.» You will see all the variables via the form at the top of the page... Including the Bowling Center you just select from the drop-down list on the previous page. How can he be passing the variable but the query (insertRegistration) indicates is not defined! UHGRRRR...

    INSERT INTO tournamentReg (tDate, tName, regDateTime, regNumber) VALUES ((param 1), (param 2), (param 3), (param 4))

    Your cfquery does not match the error. Look at the generated sql code.  Is valid or is it an extra comma in the column list?

Maybe you are looking for