我有两个页面:
1。Common.php,代码是:
<?php
$fileSystemDec = "/";
$newsDocRootURL = ".." . $fileSystemDec . ".." . $fileSystemDec . "news" . $fileSystemDec . "news";
$dbHost = "localhost";
$dbName = "fudandb";
$dbUser = "root";
$dbPwd  = "";
$applicationRootPath = "/cn";
$imagePath = $applicationRootPath . "/action/Images";
$CSSFile = $applicationRootPath . "/style.css";$insertImageTag = "<images/>";
$insertContentTag = "<news_content/>";
$insertTitleTag = "<title/>";
$insertDateTag = "<date/>";$newsCountAPage = 7;$newsTable = "news";
?>2。index.php 部分代码是:<? include("include/common.php") ?>
<? include("include/commonfunction.php") ?>
<?php
$db = mysql_connect($dbHost, $dbUser, $dbPwd);
mysql_select_db($dbName, $db);$newsRs = mysql_query("select news_id, title, release_date, release_time, base_path from " . $newsTable . " order by release_date desc, release_time desc" , $db);//获取新闻记录数
$cntRs = mysql_query("select count(*) from " . $newsTable );
$cntRow = mysql_fetch_row($cntRs);
$newsCount = $cntRow[0];
$pageCount = ceil($newsCount / $newsCountAPage);if($toPage > 1){
$firstRecordNumber = $newsCountAPage * ($toPage -1);
if($newsCount > $firstRecordNumber){
mysql_data_seek($newsRs, $firstRecordNumber);
}else{
//如果页数已经大于新闻的总页数,则退回到第一页
$toPage = 1;
}
}else{
$toPage = 1;
}
?>但是运行Index.aspx后却出现下列错误
--------------------------------------------------------------------------
PHP Warning: Undefined variable: dbHost1 in D:\webs\xyw\CN\news\index.php on line 5 PHP Warning: Undefined variable: dbUser1 in D:\webs\xyw\CN\news\index.php on line 5 PHP Warning: Undefined variable: dbPwd1 in D:\webs\xyw\CN\news\index.php on line 5 PHP Warning: Undefined variable: dbName1 in D:\webs\xyw\CN\news\index.php on line 6 PHP Warning: Undefined variable: newsTable in D:\webs\xyw\CN\news\index.php on line 8 PHP Warning: Undefined variable: newsTable in D:\webs\xyw\CN\news\index.php on line 11

解决方案 »

  1.   

    错误代码贴错了,如下:
    PHP Warning: Undefined variable: dbHost in D:\webs\xyw\CN\news\index.php on line 5 PHP Warning: Undefined variable: dbUser in D:\webs\xyw\CN\news\index.php on line 5 PHP Warning: Undefined variable: dbPwd in D:\webs\xyw\CN\news\index.php on line 5 PHP Warning: Undefined variable: dbName in D:\webs\xyw\CN\news\index.php on line 6 PHP Warning: Undefined variable: newsTable in D:\webs\xyw\CN\news\index.php on line 8 PHP Warning: Undefined variable: newsTable in D:\webs\xyw\CN\news\index.php on line 11
      

  2.   

    运行Index.aspx后却出现下列错误 ?? .aspx ??
      

  3.   

    <? include("include/common.php"); ?>
    <? include("include/commonfunction.php"); ?>
    据说在php5上要加上分号
      

  4.   

    这个是提示你变量未定义!
    因为PHP是弱类型语言,变量不需要定义拿来可以直接用,你可以在你的程序开始处加上error_reporting(E_ERROR | E_WARNING | E_PARSE);就不会提示变量没定义了!
      

  5.   

    注意文件大小写你的文件名是“Common.php”,而你在index.php中include的却是“common.php”
      

  6.   

    而且要加分号,PHP很严禁的,区分大小写