Element MOVIE_ID is undefined in UR

Posted on 2011-04-24
Last Modified: 2013-12-24
Hi.  I am VERY new at this.  I am running ColdFusion 9 using SQL+ for my DB.  I encounter an error that states "Element MOVIE_ID is undefined in URL."  Do you know how I can have the URL parameter work properly and "define" movie_id in find_detail.cfm?
Right now, I get a message saying the element is undefined in URL.  Do you know what I'm missing in order to define it?  Once it's defined, how do I reference it in find_detail.cfm?  #url.movie_id#?


    <CFQUERY NAME="movie" DATASOURCE="dba192">
       SELECT movie_id, title, category
        FROM movie NATURAL JOIN category

<cfif FORM.title IS NOT "">
WHERE movie.Title LIKE '%#FORM.title#%'

<cfif FORM.category IS NOT "">
WHERE movie.category LIKE '%#FORM.category#%'
        ORDER BY title

<TITLE>Movie Mania</TITLE>
<LINK REL=STYLESHEET TYPE="text/css" HREF="../styles.css">


<cfFORM ACTION="find_detail.cfm" METHOD="post">

<h3>Movie List (#Movie.RecordCount# movies)</h3>
<tr><td colspan="3"><hr /></td></tr>

<cfoutput query="movie">


<a href="find_detail.cfm?movie_id=#movie.movie_id#">

Question by:dshedrick
    LVL 39

    Expert Comment

    The code you posted does not have the variable URL.movie_id, so I suspect it is in your find_detail.cfm file.

    In that file, at the very top, you can add this command...

    <cfparam name="url.movie_id" default="">

    That will create an empty variable, if the variable does not exist.  That way you will never get the Not Defined error.

    The URL scoped variables exist whenever the variable is passed in the query string (the web site URL).   For example,

    In this case index.cfm should have variables URL.movie_id and URL.myName  existing

    But if you try to reference URL.user_id   it will not be defined because the above link does not contains &user_id=333


    Author Comment

    I think I am asking the wrong question.  In the find_resultsl.cfm file (previously posted), I want the user to enter a movie title into a field.  Then based on the associated movie_id, go to find_detail.cfm and return more fields from the movie DB table.  So, I'm not sure how to define movie_id from the user input to use in the find_details.cfm file.

    Is there something in the file that should send the user input to the URL?
    Is this correct:

    <a href="find_detail.cfm?movie_id=#movie.movie_id#"></a>

    or does movie_id have the wrong prefix?

    Thank you so much!!!
    LVL 39

    Accepted Solution

    I see, your code looks correct.   If your user click the movie title, then the link should open find_detail.cfm and pass in the movie_id on the url.   In find_detail.cfm, you should get the ID from the variable URL.movie_id.   It looks good.

    What problem are you having?

    Two comments:

    1) You don't need a form here at all, you have no fields and are not submitting anything.  You don't need the form tags to have a link

    2) you should scope the other variables.  YOu have some variables that come from the query "movie" that you don't have as movie.xxxx   you should always include the scope of your query with your variable.  It will make things run faster, reduce bugs and make your code easier to read


    Author Comment

    Thank you, gdemaria!!!  I now see what I wasn't "getting" before.  THank you for the other feedback as well.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    PROBLEM: How to add your own buttons to the bottom toolbar with paging info ( result count ). While creating a cfgrid, I ran into an issue where I wanted to embed my own custom buttons where the default ones ( insert / delete / etc… ) are for aes…
    Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now