【问题标题】:SQL CFoutput help, not processing when opening webpageSQL CF输出帮助,打开网页时不处理
【发布时间】:2015-03-18 18:27:17
【问题描述】:

我目前正在学习 SQL。在我的 CFM 页面上,我输入了教授给我们的所有信息。我什至与其他学生进行比较,试图找出问题所在,但他们的页面看起来像我的。请帮我弄清楚我做错了什么。谢谢。

这是网页链接http://pretendcompany.com/jaedenemployees.html

错误:

第 66 行第 32 列的 72777A 不是有效的标识符名称。 CFML 编译器正在处理:CFOUTPUT 标记的正文开始于行 62,第 3 栏。

代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<meta name="author" content="YOUR NAME HERE" />

<title>USU MIS 2100</title>

<style type="text/css" media="all">
td {
align:center;
width:955;
border:none;
text-align:center;  
vertical-align:top;
height:40px;
}


table.center{
    margin:auto;
}
h1{
font-size:26px;
color:#001F3E;  

}
h2{
font-size:20px; 
color:#ffffff;
}
img{ text-align:center;
}
td.photo{
margin:auto;    

}
</style>


</head>

<body>
<table class="center">
  <tr>
    <td  ><img src="images/header2_usu.jpg" width="755" height="265" alt="usu" /></td>
  </tr>
  <tr>
    <td style="height:900;background-color:#D7D9D9;padding-top:50px;">

    Employees by Department at Pretend Company, Inc.</font></p>
      <h1>Jaeden Harris</h1>

 <CFQUERY name="jaeden" datasource="employeedatasource">
 select Accounting,Administrative,Advertising,Payroll,Sales
 from employees
where DepartmentName in(#PreserveSingleQuotes(form.SelectDepts)#)
 </CFQUERY>

     <!--Place opening CFOUTPUT here -->
 <CFOUTPUT query="jaeden">


<table style="width:500;border:none;" class="center">
  <tr style="background-color:#72777A;">
    <td colspan="2"><h2> #DepartmentName# Employees </h2></td>
    </tr>
  <tr>
    <td style="width:250;text-align:left;">Employee:#FirstName# #MiddleName# #LastName#  
          <p>Title: #Title#
          <p>Email: #EmailName# @pretendcompany.com
          <p>Contact Number: #WorkPhone#

      </p>
      </td>
    <td style="width:140px;vertical-align:middle;" class="photo"><!--Reference Photograph field here -->      </td>
  </tr>
</table>
 </CFOUTPUT>


     </td>
  </tr>
      </table>


    </td>
  </tr>
</table>
</body>
</html>

【问题讨论】:

  • 您的页面是 HTML 文件,而不是 CFM。我会从那里开始。
  • 感谢您的关注,我完全按照她给我们的基本文件的方式下载了它,并且一直在使用 notepad++ 进行编辑,它具有 CFM 扩展名。
  • 什么没有处理?查询没有被执行吗? cfoutput 标签中的错误?
  • 您在 CFOUTPUT 中,因此任何带有 # 符号的内容都会被评估,包括样式 background-color:#72777A;。要么使用双重哈希转义那些:background-color:##72777A;,要么将样式移出 CFOUTPUT。
  • 与您的老师可能告诉您的相反,我强调功能而不是形式。换句话说,我首先让我的所有数据和其他编程代码工作,然后再担心显示代码。在这个问题的情况下,我看到一个关于 sql 和 cfml 的主题行和问题描述,然后是一堆 css。我停止阅读。太多的谷壳掩盖了小麦。

标签: sql ms-access coldfusion


【解决方案1】:

您在 CFOUTPUT 中,因此任何带有 # 符号的东西都会被评估,包括样式 background-color:#72777A;。要么使用双重哈希转义那些:background-color:##72777A;,要么将样式移出您的 CFOUTPUT。

由于您已经有一个 CSS 部分,因此明智的做法是将所有表格样式从 HTML 内联移动到顶部,然后将类应用于您的元素。

【讨论】:

  • 好吧,这肯定有帮助,但现在我遇到了错误:
  • 执行数据库查询时出错。 [Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] 参数太少。预计 5。
  • 我不熟悉 MS Access 的语法。我最初的假设是您的 IN () 子句中有错误。 form.SelectDepts 有值吗?
  • 我可能在这里过得很好,但我确信该错误意味着您的查询中的数据库字段名称不正确,在这种情况下有 5 个错误!
  • 这绝对是可能的。另一个是IN (#PreserveSingleQuotes(form.SelectDepts)#) 子句。如果单个值 inside 该字段没有被引用 - 即 ABC,EDF 而不是 'ABC','EDF', ... Access 可能会认为它们是对象名称,这可能会导致相同错误。也就是说,使用PreserveSingleQuotes 是一种不好的做法。相反,您应该将 与“list”属性一起使用。 @JaedenHarris - S.O.不同于论坛。在回答了您最初的问题后,您应该发布一个关于新 SQL 错误的单独问题。
猜你喜欢
  • 1970-01-01
  • 2022-07-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-03-28
  • 1970-01-01
  • 1970-01-01
  • 2021-10-23
相关资源
最近更新 更多