好的,我有这个代码。
<?//index.php
if(!defined('INCLUDE_CHECK')) die('You are not allowed to execute this file directly');
include('db.php');//include our database
//connecting to the database
$con = mysql_connect($dbhost, $dbusername, $dbpassword);
//if we cant connect
if (!$con)
{
die ('could not connect to the database' . mysql_error());
}
//if successfully connected then select db
mysql_select_db ($dbtable, $con);
//our query
$result = mysql_query("SELECT * FROM header");
//fetch our result
while($row = mysql_fetch_array($result)) //this is the line 18
{
//if type is meta then..
if ($row['type'] === "meta")
{
$meta .= "<meta name='".$row['name']."' content='".$row['content']."' />";
}
//if type is title then..
elseif ($row['type'] === "title")
{
$title = "<title>".$row['content']."</title>";
$title2 = "<div id='ti'>".$row['name']."</div>";
}
//if type is favicon then..
elseif ($row['type'] === "favicon")
{
$favicon = "<link rel='shortcut icon' href='".$row['content']."' />";
$imglogo = "<img class='imglogo' src='".$row['content']."' />";
}
//if type is description then..
elseif ($row['type'] === "description")
{
$des = "<div id='ti2'>".$row['content']."</div>";
}
}
mysql_close($con);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<? echo $title; //line 50 ?>
<? echo $favicon; //line 51 ?>
<? echo $meta; //line 52 ?>
<? echo (file_get_contents("cc.txt")); ?>
</head>
我收到以下错误,警告:mysql_fetch_array() 期望参数 1 是资源,在第 18 行的 C:\xampp\htdocs\wr\header.php 中给出的布尔值
注意:未定义变量:第 50 行 C:\xampp\htdocs\wr\header.php 中的标题
注意:未定义的变量:第 51 行 C:\xampp\htdocs\wr\header.php 中的 favicon
注意:未定义变量:第 52 行 C:\xampp\htdocs\wr\header.php 中的元
错误行是在代码中指定的,请参阅错误行的顶部代码。
有人可以帮我解决这个问题吗?提前致谢。
朱利弗。