本页主题: 求教一个ASP编程问题,ASP达人请进~ 打印 | 加为IE收藏 | 复制链接 | 收藏主题 | 上一主题 | 下一主题

bbsriver
杀人游戏MVP勋章I 杀人游戏MVP勋章II
级别: 管理员


精华: 52
发帖: 17392
威望: 8730 点
金钱: 7074 静电币
支持度: 19001 点
在线时间:13725(小时)
注册时间:2002-11-21
最后登录:2016-12-22

 求教一个ASP编程问题,ASP达人请进~

最近开始学ASP。基础的变量和语法都还没看,靠着以前学过点VBA和PHP的底子,就直接看网页代码。遇到看不懂的代码再直接去搜每个语句的含义。夹生饭似的学下去。

结果遇到这么一段代码:


<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!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">
<%
article_id=cint(trim(request.querystring("id")))
%>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link href="images/cssBasic.css" rel=stylesheet" type="text/css" />
<link href="images/cssLawCase.css" rel="stylesheet" type="text/css" />
<!--#include file="include/connect_mysites_new.asp" -->
<%
set rs=Server.CreateObject("Adodb.Recordset")
rs.open "select * from Article where id="&article_id,conn,1,1
if not rs.eof and not rs.bof then
  total_title=rs("title")
  end if
%>
<title><%=totle_title%></title>
    <style type="text/css">
        .style1
        {
            width: 233px;
        }
        .style2
        {
            width: 1175px;
        }
        .style3
        {
            table-layout: fixed;
            width: 1175px;
        }
    </style>
</head>
<body>
……

如果我把
<%
set rs=Server.CreateObject("Adodb.Recordset")
rs.open "select * from Article where id="&article_id,conn,1,1
if not rs.eof and not rs.bof then
  total_title=rs("title")
  end if
%>
这段代码放在
<!--#include file="include/connect_mysites_new.asp" -->
这行语句的前面,就一定会报错:http500
而放在这行语句的后面,网页显示就完全正常。

所以,
<!--#include file="include/connect_mysites_new.asp" -->
这行代码的含义是什么?为什么必须放在调用数据库的代码之前才能正常工作?
这行代码不是已经被<!-- -->注释掉了吗?为什么还在发挥作用?
请指教~
Posted: 2010-08-10 12:49 | [楼 主]
galilette
级别: 嘉宾


精华: 30
发帖: 2139
威望: 1382 点
金钱: 0 静电币
支持度: 0 点
在线时间:3012(小时)
注册时间:2002-05-01
最后登录:2019-03-12

 

http://www.w3schools.com/asp/asp_incfiles.asp

这个用google搜索 asp, "#include" directive出来的第一条
Posted: 2010-08-10 15:07 | 1 楼
天堂有令
☆圣风
级别: 嘉宾


精华: 0
发帖: 4348
威望: 2770 点
金钱: 0 静电币
支持度: 42 点
在线时间:2889(小时)
注册时间:2006-03-31
最后登录:2019-04-04

 

恩 那个只是include的写法,并不是注释
Quote:
To include a file in an ASP page, place the #include directive inside comment tags:


浏览器是顺序编译的,所以先用到的东西要放在前面,顺序很重要

PS:大头狗发的这个网站可是王牌网站,w3school
Posted: 2010-08-11 10:29 | 2 楼
bbsbird
轻尘
级别: 贵宾


精华: 3
发帖: 3038
威望: 836 点
金钱: 3075 静电币
支持度: 11 点
在线时间:176(小时)
注册时间:2003-10-16
最后登录:2012-07-23

 

没理解错的话 connect_mysites_new.asp 应该链接数据库的asp网页文件,一般多写做conn.asp

<!--#include file="xxx.asp" --> 直白点理解就是调用这个xxx.asp文件

出去有事 待续
深夜来临的时候,是一个人心灵最脆弱的时候,也是思念最疯狂的时候。其实一个人并不孤单,想念一个人的时候才是真正的孤单。
Posted: 2010-08-16 13:08 | 3 楼
bbsriver
杀人游戏MVP勋章I 杀人游戏MVP勋章II
级别: 管理员


精华: 52
发帖: 17392
威望: 8730 点
金钱: 7074 静电币
支持度: 19001 点
在线时间:13725(小时)
注册时间:2002-11-21
最后登录:2016-12-22

 

嗯嗯,最近开始看conn.asp了,这东西正是干这个用的。

看到conn.asp之后,发现没法跳着看代码了,必须找本书来从头学SQL操作的基本知识。
Posted: 2010-08-21 00:44 | 4 楼
bbsriver
杀人游戏MVP勋章I 杀人游戏MVP勋章II
级别: 管理员


精华: 52
发帖: 17392
威望: 8730 点
金钱: 7074 静电币
支持度: 19001 点
在线时间:13725(小时)
注册时间:2002-11-21
最后登录:2016-12-22

 

刚刚知道原来ASP的核心就是VBScript。我说怎么学起来这么容易,原来大部分和VBA是重叠的……
Posted: 2010-09-02 23:40 | 5 楼
galilette
级别: 嘉宾


精华: 30
发帖: 2139
威望: 1382 点
金钱: 0 静电币
支持度: 0 点
在线时间:3012(小时)
注册时间:2002-05-01
最后登录:2019-03-12

 

没办法, 谁让比尔盖茨是靠basic发家的呢
Posted: 2010-09-03 09:06 | 6 楼
piaohr
级别: 精灵王


精华: 0
发帖: 395
威望: 177 点
金钱: 1335 静电币
支持度: 1 点
在线时间:28(小时)
注册时间:2005-12-22
最后登录:2012-03-21

 

Quote:
引用第6楼galilette于2010-09-03 09:06发表的  :
没办法, 谁让比尔盖茨是靠basic发家的呢

Posted: 2010-09-03 10:09 | 7 楼
帖子浏览记录 版块浏览记录
狗狗静电BBS - wwW.DoGGiEhoMe.CoM » 电脑全方位 Computer Guide

沪ICP备05008186号
Powered by PHPWind Styled by MagiColor