这是我的 dbconnect.class.php
<?php
class Connect
{
//public $error;
public $db;
public function __construct()
{
$link = mysql_connect("localhost","root","1");
$db = mysql_select_db("tarih",$link);
$this->db = $db;
}
}
$connect = new Connect();
$connect = $connect->db;
?>
这是主要的php文件(header.class.php)
<?php
require_once ('dbconnect.class.php');
class Header extends Connect
{
public $headers = array();
public function __construct()
{
/*
* Bu sınıf sayfaların header bilgilerini işler.
*/
}
public function sayfaHeader($sayfa = true)
{
$sql = "SELECT * FROM header WHERE id='" . $sayfa . "'";
$query = mysql_query($sql,$connect) or mysql_error();
echo $sql;
}
}
$header = new Header();
echo $header->sayfaHeader();
?>
但是当我运行这段代码时,我看到了这个错误:
警告:mysql_query():提供的参数不是第 16 行 C:\AppServ\www\ilk\class\header.class.php 中的有效 MySQL-Link 资源
问题是什么?