Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 517
  • Last Modified:

Element MOVIE_ID is undefined in UR

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>

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

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

<BODY>

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

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

<cfoutput query="movie">

<tr>
<td>
#CurrentRow#:

<a href="find_detail.cfm?movie_id=#movie.movie_id#">
#Title#</a>
</td>
<td>
#category#
</td>
</tr>
</cfoutput>
</table>

</cfform>
</body>
</html>
0
dshedrick
Asked:
dshedrick
  • 2
  • 2
1 Solution
 
gdemariaCommented:
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,  www.myDomain.com/index.cfm?movie_id=123&myName=Fred

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


0
 
dshedrickAuthor Commented:
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!!!
0
 
gdemariaCommented:
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

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

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now