|
|
|
| Помогите найти ошибку,
class db {
var $db_type;
var $db_server;
var $db_name;
var $db_user;
var $db_pass;
var $db_persistent;
var $dbh;
function db() {
$this->db_type = 1;
$this->db_server = 'localhost';
$this->db_name = 'ballans';
$this->db_user = 'user';
$this->db_pass = 'pass';
$this->db_persistent = 0;
$this->db_connect();
}
function db_connect () {
if($this->db_type == 1) {
if ($this->db_persistent)
$this->dbh = @mysql_pconnect($this->db_server, $this->db_user, $this->db_pass);
else
$this->dbh = @mysql_connect($this->db_server, $this->db_user, $this->db_pass);
if (!$this->dbh) {
echo("Ошибка соединения");
echo($this->db_server);
return;
}
if (!@mysql_select_db($this->db_name, $this->dbh)) {
echo("Ошибка соединения");
echo( $this->db_name);
echo( @mysql_error($this->dbh));
echo( @mysql_error($this->dbh));
return;
}
}
}
function db_query ($query)
{
if($this->db_type == 1) {
$result = mysql_query($query, $this->dbh) //выдает что ошибка в этой строке
or die ("Ошибка соединения");
return $result;
}
}
function db_numrows ($result) {
switch($this->db_type) {
case 1:
return mysql_num_rows($result);
}
}
function db_fetch_array (&$result) {
switch($this->db_type) {
case 1:
return mysql_fetch_array($result);
}
}
} Вызов
<?
include("Pass.php");
$ob=new db();
$ob->db_connect();
$ob->db_query("query");
?> | |
|
|
|
|
|
|
|
для: elenaM
(01.07.2007 в 01:28)
| | Приведите точное сообщение об ошибке? | |
|
|
|
|
|
|
|
для: cheops
(02.07.2007 в 22:12)
| | $ob=new db(); - тут уже выполнилась функция db_connect(), а вы следующей строчкой опять ее выполняете. | |
|
|
|
|
|
|
|
для: elenaM
(01.07.2007 в 01:28)
| | мало "@", очень мало, их не хватает чтобы даже ошибку показать | |
|
|
|