Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default variable?error

    I have this sql but something isnt quite right
    could someone kindly point me in the right direction please

    Search Page
    SELECT Language_name
    FROM tslanguage

    Result page
    select a.Hospital_Name, a.English, a.Russian
    from tsHospital a, tsLanguage b, tshsptlang c
    where a.Hosptial_ID = c.Hospital_ID
    and b.Language_ID=c.Language_ID
    and b.Language_Name=#cflanguage_variable#

    I get an error about the cflanguage_variable

    any ideas

    cant seem to sort it out

    Regards Mark

    quiero mas Guest

  2. Similar Questions and Discussions

    1. Error: Undefined variable
      I am going trough the ColdFusion "Record store tutorial" I found on Macromedia's web site: ...
    2. Undefined variable notice error
      In response to several previous emails: You might get an error message like this when a post or get variable is not set by default, like when a...
    3. using Error opening URL as a variable
      Does anyone know how to use ? Error opening URL ?as a variable I have a flash animation which loads m3u playlists and I want to enable it to...
    4. Error: Must Declare Variable
      I have the following code upon which I receive the error "Must declare the variable '@job_id'". --Begin Code -- OleDbConnection conDetail =...
    5. Perl FAQ error in "variable as a variable name"
      In trying to learn about references, I believe I've found an error in the Perl FAQ, section 7 ("General Perl Language Issues"), under the question,...
  3. #2

    Default Re: variable?error

    I see two potential problems. The first is that you are referring to a
    variable that doesn't exist. The second is that language_name looks like a
    char field and you don't have quotes around the variable.



    Dan Bracuk Guest

  4. #3

    Default Re: variable?error

    Just to elaborate:

    Your search form page must contain a text box or selector named
    cflanguage_variable.

    Then on the result page, this:
    and b.Language_Name=#cflanguage_variable#

    becomes this:
    and b.Language_Name = <cfqueryparam value=#FORM.cflanguage_variable#
    CFSQLType="CF_SQL_VARCHAR">



    If cflanguage_variable is not from a form use an appropriate <CFPARAM>
    statement at the top of your results file.
    (Actually, use the <cfparam> even if cflanguage_variable IS a form variable.)


    MikerRoo Guest

  5. #4

    Default Re: variable?error

    much appreciated - i want to make this into a teo select search.
    one drop down enu populating the next.
    example after choosing the language the user is able to then select the
    location.

    am i going about the process right? First get this one sorted te n move onto
    the location one. then bring tem all together somehow. or should i be thinking
    about this in another way?

    thanks again for all the help
    been away on business in Kyoto - was glad to see you both still here

    quiero mas Guest

  6. #5

    Default Re: variable?error

    The best way to do that is to use Ajax to dynamically populate things.

    Google CFAjax.

    MikerRoo Guest

  7. #6

    Default Re: variable?error

    Take a look at this example: [url]http://www.indiankey.com/cfajax/examples/list.htm[/url]
    MikerRoo Guest

  8. #7

    Default Re: variable?error

    thanks miker
    I gave it a try still a final tweak needed i think
    I have heard about ajax - will start reading up on things

    Search Page
    <cfquery name="SearchLanguage" datasource="simple">
    SELECT Language_name
    FROM tslanguage</cfquery>
    <form action="ResultLanguage.cfm" method="get">

    <input type="submit" name="Submit" value="Submit">
    <select name="cflanguage_variable">
    <cfoutput query="SearchLanguage">
    <option value="#SearchLanguage.Language_name#" <cfif
    (isDefined("SearchLanguage.Language_name") AND SearchLanguage.Language_name EQ
    SearchLanguage.Language_name)>selected</cfif>>#SearchLanguage.Language_name#</op
    tion>
    </cfoutput> </select>

    </form>

    Result page
    <cfparam name="FORM.cflanguage_variable" default="1">
    <cfquery name="gethospital" datasource="simple">
    select a.Hospital_Name, a.English, a.Russian
    from tsHospital a, tsLanguage b, tshsptlang c
    where a.Hosptial_ID = c.Hospital_ID
    and b.Language_ID=c.Language_ID
    and b.Language_Name = <cfqueryparam value=#FORM.cflanguage_variable#
    CFSQLType="CF_SQL_VARCHAR">
    </cfquery>


    I get an error telling me russina is not the default - tried a few combos - no
    go

    any ideas

    cant seem to sort it out

    Regards Mark

    quiero mas Guest

  9. #8

    Default Re: variable?error

    just had a look at the populating example - nice example very clear. thanks
    after the drop downs have been populated - the next step is the sql on the
    result page?
    Is it hard to write the sql for something like what i want to achieve - i
    guess once i ve done it once these these become much easier
    thank you again miker
    great tips
    Mark

    quiero mas Guest

  10. #9

    Default Re: variable?error

    Huh?

    Please paste the EXACT error and indicate what page it is on.
    Be sure to include the generated SQL that is in the error message.
    MikerRoo Guest

  11. #10

    Default Re: variable?error

    I have to run off but just noticed...

    This code: <cfif (isDefined("SearchLanguage.Language_name") AND
    SearchLanguage.Language_name EQ SearchLanguage.Language_name)>selected</cfif>

    Should have the effect of selecting every value! Is this what you want?

    Also, if the select can have multiple values you need to change the result
    query.

    Change the relevant line to this:
    and b.Language_Name IN <cfqueryparam list="yes"
    value=#FORM.cflanguage_variable# CFSQLType="CF_SQL_VARCHAR">

    (Syntax not checked)

    MikerRoo Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139