From b8757fb45624d038e1f072fa40fb439608532164 Mon Sep 17 00:00:00 2001 From: Friendika Date: Thu, 3 Mar 2011 15:41:08 -0800 Subject: make sure db queries never get called if the database isn't open --- include/dba.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'include/dba.php') diff --git a/include/dba.php b/include/dba.php index b05a1cabf..b89648bca 100644 --- a/include/dba.php +++ b/include/dba.php @@ -20,12 +20,14 @@ class dba { function __construct($server,$user,$pass,$db,$install = false) { $this->db = @new mysqli($server,$user,$pass,$db); - if((mysqli_connect_errno()) && (! $install)) { + if(! mysql_connect_errno()) { + $this->connected = true; + } + else { $this->db = null; - system_unavailable(); + if(! $install) + system_unavailable(); } - else - $this->connected = true; } public function getdb() { @@ -34,7 +36,7 @@ class dba { public function q($sql) { - if(! $this->db ) + if((! $this->db) || (! $this->connected)) return false; $result = @$this->db->query($sql); @@ -92,7 +94,8 @@ class dba { } public function escape($str) { - return @$this->db->real_escape_string($str); + if($this->db && $this->connected) + return @$this->db->real_escape_string($str); } function __destruct() { -- cgit v1.2.3 From 69e2252fd6fc8acd8bf5b0fcecd8c329d71c9673 Mon Sep 17 00:00:00 2001 From: Friendika Date: Thu, 3 Mar 2011 15:47:13 -0800 Subject: that would be mysql !i! connect_errno... --- include/dba.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/dba.php') diff --git a/include/dba.php b/include/dba.php index b89648bca..d75ed560a 100644 --- a/include/dba.php +++ b/include/dba.php @@ -20,7 +20,7 @@ class dba { function __construct($server,$user,$pass,$db,$install = false) { $this->db = @new mysqli($server,$user,$pass,$db); - if(! mysql_connect_errno()) { + if(! mysqli_connect_errno()) { $this->connected = true; } else { -- cgit v1.2.3