Call Toll Free!
   packages   ::    about us   ::   support   ::   contact   ::   network   ::   F.A.Q.
    home

 

Programming in ColdFusion

back to index

    1. Code Examples
    2. Connecting to MySQL
    3. Session Variables
    4. CFMX Programming Links

    1. Code Examples

    2. 
      
      
      <!--- shows the value of the dayofWeek function --->
      
      <cfif IsDefined("form.year")>
      More information about your date:
      <cfset yourDate = #CreateDate(form.year, form.month, form.day)#>
      
      <cfoutput>
      <p>Your date, #DateFormat(yourDate)#.
      <br>It is #DayofWeekAsString(DayOfWeek(yourDate))#, day #DayOfWeek(yourDate)# in the week.
      <br>This is day #Day(YourDate)# in the month of #MonthAsString(Month(yourDate))#, which has #DaysInMonth(yourDate)# days.
      <br>We are in week #Week(yourDate)# of #Year(YourDate)# (day #DayofYear(yourDate)# of #DaysinYear(yourDate)#).  
      <br><cfif IsLeapYear(Year(yourDate))>This is a leap year<cfelse>This is not a leap year</cfif>
      </cfoutput>
      
      </cfif>
      
      
      <cfform action="index.cfm" method="POST">
      <p>Please enter the year, month and day in integer format for 
      the date value you would like to view:
      <pre>
      Year	<cfinput type="Text" name="year" value="1998" validate="integer" required="Yes">
      Month	<cfinput type="Text" name="month" value="6" validate="integer" required="Yes">
      Day	<cfinput type="Text" name="day" value="8" validate="integer" required="Yes">
      </pre>
      <p><input type="Submit" name=""> <input type="RESET">
      
      
      </cfform>
      
      
      
      
      
      				

      top

    3. Connecting to MySQL

    4. 
      			
      <CFQUERY DATASOURCE=”CFdata” NAME=”getall”> SELECT * FROM Info ORDER BY Name ASC </CFQUERY> Then below this code, add the following HTML: <table align=”center” border=”1”> <CFOUTPUT QUERY=”getall”> <tr> <td>#CURRENTROW#</td> <td>#NAME#</td> <td>#ADDRESS#<BR>#CITY# #STATE#, #ZIP#</td> <td>#PHONE#</td> <td>#EMAIL#</td> <td>#NOTES#</td> </tr> </CFOUTPUT> </table>

      top

    5. Session Variables

    6. You will need to create a file called "Application.cfm" (make sure that the A is a capital "A" and not "a"...this is a common problem from those who were in a Windows environment before moving to our servers.)

      Once you have created your Application.cfm file, you will need to place some code on the page to tell ColdFusion what to enable and how long they should persist. We do this using the <cfapplication> tag. Below is a table of variables available to the <cfapplication> tag.

      Table 1
      ATTRIBUTE NOTES
      NAME Required; provides a name for our application. Name limited to 64 characters.
      CLIENTMANAGEMENT Optional; enables client management (client variables) for the application. Defaults to no.
      CLIENTSTORAGE Optional; determine where client variables are stored. Available values are "Registry, Cookie, or you may enter the name of a database for storage". Defaults to registry.
      SESSIONMANAGEMENT Optional; enables session management (session variables) for the application. Defaults to no.
      SESSIONTIMEOUT Optional; sets the timeout value for session variables. Defaults to the value established in the ColdFusion Administrator.
      APPLICATIONTIMEOUT Optional; sets the timeout value for application variables. Defaults to the value established in the ColdFusion Administrator.
      SETCLIENTCOOKIES Optional; enables client cookies. Defaults to yes. If disabled you must pass the CFID and CFTOKEN variables manually for page to page.
      SETDOMAINCOOKIES Optional; determines if client cookies should be set at the domain level. Useful for servers running in a clustered environment. Defaults to no.

      At its most basic, your <cfapplication> tag should have the following elements:

      • Name
      • SessionManagement
      • SessionTimeout

      With the above in mind, here is a basic implementation of the <cfapplication> tag:

      <cfapplication name="myApp"
       sessionmanagement="yes"
       sessiontimeout="#CreateTimeSpan(0,0,20,0)#">

      top

    7. CFMX Programming Links

    8. here are some excellent sites that have help forums and code examples:
      :: Macromedia
      :: Hot Scripts

      top

      back to index


©2000-08 PerformanceHosting.net,Inc. All Rights Reserved. Privacy Policy