gpt4 book ai didi

mysql - 输出所有结果?

转载 作者:太空宇宙 更新时间:2023-11-03 12:18:37 26 4
gpt4 key购买 nike

我一直在尝试在 ColdFusion 中创建我自己的论坛脚本,但遗憾的是,这比我想象的要困难得多。我在尝试显示数据库中的所有评论时卡住了,因为 ColdFusion 向我抛出错误。

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">
<strong>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></strong>
198: <p>Berichten: 55</p>
199:

我为这个脚本编写的代码如下:

<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>

我真的不知道我做错了什么,也不知道为什么 ColdFusion 给我这个错误。我将不胜感激所有的帮助!我唯一的猜测是 ColdFusion 试图(再次)从第一条评论的发帖人那里获取所有数据,但这是错误的,因为我想获取评论 1、评论 2,以及之后的评论 3、4、5 等等。

此外,在向主题添加第一条评论时,一切正常。但是在添加第二个之后,我得到了您在上面看到的错误。

问候,亚尼克

最佳答案

我的猜测是因为你有一个 <cfif>在“reageer”查询周围,发生错误是因为有超过 1 个评论,但 username 的输出未包裹在 <cfif> 中以及。因此,ColdFusion 试图获取 username 的值。来自不存在的查询(因为 <cfif> 阻止它执行),因此出现错误。

关于mysql - 输出所有结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21062620/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com