I've been trying to create my own forum script in ColdFusion, but sadly, it's a lot more difficult then I thought that it would be. I'm getting stuck when trying to display ALL the comments from the database, because ColdFusion throws me errors.
The following information is meant for the website developer for debugging purposes.
Error Occurred While Processing Request
Element USERNAME is undefined in REAGEER.
The error occured in C:/inetpub/wwwroot/content/1-Home/topicview.cfm: line 197
195: 196: <div id="pers_info"> 197: <a href="/">#reageer.username#</a> <cfif #reageer.online# is 1><img src="http://www.wonderhotel.nl/archive/icons/mini/habbo_online_anim.gif"></img><cfelse><img src="http://www.wonderhotel.nl/archive/icons/mini/habbo_offline.gif"></img></cfif></strong> 198: <p>Berichten: 55</p> 199:
The code I wrote for this script is the following:
<cfif IsDefined('URL.id') and URL.id neq ""> // Get the topic ID
<cfquery name = "comments" datasource = "#DSN#">
SELECT *
FROM `forum_comments`
WHERE topicid = #id#
</cfquery> // Get the comments
<cfif #comments.RecordCount# is 1>
<cfquery name = "reageer" datasource = "#DSN#">
SELECT *
FROM `users`
WHERE id = #comments.poster#
</cfquery> // Get the comment posters
</cfif>
<cfset colour ="post_uneven">
<cfloop query="comments">
<div id="#colour#">
<div id="pers_info">
<a href="/">#reageer.username#</a> <cfif #reageer.online# is 1><img src="http://www.wonderhotel.nl/archive/icons/mini/habbo_online_anim.gif"></img><cfelse><img src="http://www.wonderhotel.nl/archive/icons/mini/habbo_offline.gif"></img></cfif>
<p>Berichten: 55</p>
<cfquery name = "reageer_badge_one" datasource = "#DSN#">
SELECT *
FROM `user_badges`
WHERE user_id = '#reageer.id#'
AND badge_slot = 1
</cfquery>
<cfquery name = "reageer_badge_second" datasource = "#DSN#">
SELECT *
FROM `user_badges`
WHERE user_id = '#reageer.id#'
AND badge_slot = 2
</cfquery>
<div id="pers_info_habbo">
<img src="http://habbo.nl/habbo-imaging/avatarimage?figure=#reageer.look#.gif">
</div>
<div id="pers_info_grbadge">
<cfif #reageer_badge_one.RecordCount# is 1>
<img src="http://wonderhotel.nl/Public/Images/badges/#reageer_badge_one.badge_id#.gif">
</cfif>
</div>
<div id="pers_info_badge">
<cfif #reageer_badge_second.RecordCount# is 1>
<img src="http://wonderhotel.nl/Public/Images/badges/#reageer_badge_second.badge_id#.gif">
</cfif>
</div>
<div id="pers_info_missie">
#reageer.motto#
</div>
</div>
<div id="post_text">
<a href="/"><div id="post_text_edit" title="Bericht aanpassen"></div></a>
<a href="/"><div id="post_text_delete" title="Bericht verwijderen"></div></a>
<div id="post_text_title">
RE: #gettopic.title#
</div>
<div id="post_text_date">
#DateFormat(dateAdd("s", comments.timestamp, "01/01/1970"))# #TimeFormat(dateAdd("s", comments.timestamp, "01/01/1970"))#
</div>
<div id="post_text_text">
#comments.text#
</div>
</div>
</div></div>
<cfif colour is "post_uneven"><cfset colour="post_even"><cfelse><cfset colour="post_uneven"></cfif>
</cfloop>
</cfoutput>
<div id="topic_info_balk"> // Useless
<div id="forum_paginas">
Bekijk pagina:
1
<a href="#">2</a>
<a href="#">3</a>
<a href="#">4</a>
<a href="#">5</a>
<a href="#">6</a>
<a href="#">7</a>
<a href="#">8</a>
<a href="#">9</a>
<a href="#">10</a>
<a href="#">>></a>
</div>
<div id="reageer-topic">
<a href="/topic/<cfoutput>#gettopic.id#</cfoutput>/comment">Reageer</a>
</div>
</div>
</div>
I really don't know what I'm doing wrong, and why ColdFusion gives me this error. I would appreciate all the help! My only guess is that ColdFusion tries to get all the data (again) from the poster of the first comment, but that would be wrong because I want to get comment 1, comment 2, and afterwards 3, 4, 5, etcetera.
Also, when adding the first comment to the topic, everything works fine. But after adding the second, I get the error that you can see above.
Regards, Yannick
SELECT *
in scripts or software. Always enumerate the columns you want to retrieve. It seems likely that there's something wrong withusername
as a column name. – O. Jones