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

x
?
Solved

Detail page element undefined

Posted on 2006-03-29
10
Medium Priority
?
217 Views
Last Modified: 2013-12-24
I am creating a web-site that features a detail page which is supposed to display whenever a user clicks on a hyperlink in a results page posted from a search query

Here is the code from the detail page

<cfquery name="details" datasource="#Request.dsn#">
SELECT *
FROM MLS
LEFT OUTER JOIN TblPicPaths
ON TblPicPaths.mlsid = mls.mlsid
WHERE MLS.mlsid= #url.mlsid#
</cfquery>

When I click on the hyperlink on the results page I get this error

Element MLSID is undefined in URL.
The error occurred in D:\Hosting\lairson\detail_page.cfm: line 6
 
4 : LEFT OUTER JOIN TblPicPaths
5 : ON TblPicPaths.mlsid = mls.mlsid
6 : WHERE MLS.mlsid= #url.mlsid#
7 : </cfquery>
8 : <html>

 
Can someone give me some suggestions on how to correct my code
0
Comment
Question by:rudodoo
  • 4
  • 3
8 Comments
 
LVL 25

Accepted Solution

by:
dgrafx earned 500 total points
ID: 16320939
In the hyperlink on the results page - you must not have mlsid as in:
a href="results.cfm?stuff=#stuff#&mlsid=#mlsid#
0
 

Author Comment

by:rudodoo
ID: 16321495
Already figured it out thanks anyway
0
 
LVL 7

Assisted Solution

by:JeffHowden
JeffHowden earned 500 total points
ID: 16329653
Make sure to "param" url.mlsid to a default value in case it's not passed in the url.

<cfparam name="url.mlsid" default="0">

<cfquery name="details" datasource="#Request.dsn#">
  SELECT *
    FROM MLS LEFT OUTER JOIN TblPicPaths
        ON TblPicPaths.mlsid = mls.mlsid
  WHERE MLS.mlsid= #Val(url.mlsid)#
</cfquery>
0
[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

 
LVL 25

Expert Comment

by:dgrafx
ID: 16331875
>>rudodoo
DON'T default it to zero or any other number.
This is not a situation for a default param.
This is a situation for if it is not defined - you need to send them "back" to define it.

Glad you have it figured out though
0
 
LVL 7

Expert Comment

by:JeffHowden
ID: 16334814
Actually, sending them back to define it is poor design and an incorrect to the requested action.  If your application is designed properly, they should never need to go back to define it unless they're either messing with the url or they've bookmarked a URL with an mlsid that no longer exists.  It'd be more appropriate to give the user a 404 if it's not defined or the value sent results in the query not returning a result.  So, paraming it to 0 and dealing with a query that doesn't return a resultset is easier than having to test if the variable is defined *and* testing for a recordcount separately.  What you're suggesting will require more logic branching to accomplish unless you insist on incorrectly redirecting the user.

Again, from years of experience, here's my suggested approach:

<cfparam name="url.mlsid" default="0">

<cfquery name="details" datasource="#Request.dsn#">
  SELECT *
    FROM MLS LEFT OUTER JOIN TblPicPaths
        ON TblPicPaths.mlsid = mls.mlsid
  WHERE MLS.mlsid= #Val(url.mlsid)#
</cfquery>

<cfif NOT details.recordcount>
  <cfheader statuscode="404" statustext="File Not Found">
<cfelse>
  <!--- output the query results --->
</cfif>
0
 
LVL 25

Expert Comment

by:dgrafx
ID: 16335115
>>Jeff
You must know I did not mean to just send them back, even though I used "back" in my statement.
I meant along the lines of if Not isDefined("thevar")  then send them to an appropriate page, because yes, it usually means the url vars are being messed with or it is a bot etc.

In general, questions answered here do not provide the entire code or solution, but are "how to" tips to get the question asker going.
Then if questions are still asked, a person can post additional details.
Some of the question askers here are complete newbees (sp?) and some are advanced developers with an issue.
It's generally outside the scope of most questions to get into or even touch upon all the aspects of building a quality application.
The question asker either knows this "stuff" or not, and if not then they'll learn it someday or not, and will become a quality developer or not.
0
 
LVL 7

Expert Comment

by:JeffHowden
ID: 16337012
Well, we apparently have a difference of opinion on how to answer questions.  I prefer to give as much detail as possible and to give insight into quality application development as possible too.  I'd rather assume they didn't know the "stuff" as something I may add based on that assumption could be a new perspective even a seasoned developer may not have heard.
0
 
LVL 25

Expert Comment

by:dgrafx
ID: 16337340
Fair enough Jeff!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

580 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