Προς το περιεχόμενο

PHP problem


zazik

Προτεινόμενες αναρτήσεις

geia sas

eimai poli newbie stin php

kai thelo na mou peite pou ine to bug.....

paratheto tous kodikes...

>
if (!defined('CPG_NUKE')) {
   die("You can't access this file directly...");
}

if(!defined("SQL_LAYER"))
{

define("SQL_LAYER","mysql");

class sql_db
{

   var $db_connect_id;
   var $query_result;
   var $row = array();
   var $rowset = array();
   var $num_queries = 0;
   var $time = 0;
   var $query_ids = array();
//    var $querylist;

   //
   // Constructor
   //
   function sql_db($sqlserver, $sqluser, $sqlpassword, $database, $persistency = true)
   {
       $stime = get_microtime();
       $this->persistency = $persistency;
       $this->user = $sqluser;
       $this->password = $sqlpassword;
       $this->server = $sqlserver;
       $this->dbname = $database;

       if($this->persistency)
       {
           $this->db_connect_id = @mysql_pconnect($this->server, $this->user, $this->password);
       }
       else
       {
           $this->db_connect_id = @mysql_connect($this->server, $this->user, $this->password);
       }
       if($this->db_connect_id)
       {
           if($database != "")
           {
               $this->dbname = $database;
               $dbselect = @mysql_select_db($this->dbname);
               if(!$dbselect)
               {
                   @mysql_close($this->db_connect_id);
                   $this->db_connect_id = $dbselect;
                   define("NO_DB", 1);
               }
           }
           $this->time += (get_microtime()-$stime);
           return $this->db_connect_id;
       }
       else {
           return false;
       }
   }

   //
   // Other base methods
   //
   function sql_close()
   {
       if($this->db_connect_id) {
           $numid = count($this->query_ids);
           for ($i=0; $i<$numid; $i++) {
               if (isset($this->query_ids[$i])) { @mysql_free_result($this->query_ids[$i]); }
           }
           if (!$this->persistency) {
               $result = @mysql_close($this->db_connect_id);
               $this->db_connect_id = NULL;
               return $result;
           }
           return false;
       }
       else
       {
           return false;
       }
   }

   //
   // Base query method
   //
   function sql_query($query = "", $bypass_error = FALSE)
   {
       if (CPGN_DEMO) {
           global $admin;
           if (isset($admin)) {
               if (!is_array($admin)) {
                   $admin1 = base64_decode($admin);
                   $admin1 = explode(":", $admin1);
               }
               if (eregi("demo", $admin1[0])) {
                   if (strtoupper(substr($query, 0, 6)) != "SELECT") {
                       return NULL;
                   }
               }
           }
       }

       if (!$this->db_connect_id) {
           $the_error = "While executing query \"$query\"\n\nIt seems the database connection was closed.";
           sqldb_error($the_error, $bypass_error, 1);
       }
       $stime = get_microtime();
       // Remove any pre-existing queries
       unset($this->query_result);
       if($query != "") {
           // check if it is a SELECT query
           if (strtoupper($query[0]) == 'S') {
               // SPLIT when theres 'UNION (ALL|DISTINT|SELECT)'
               $query_parts = preg_split('/(union)([\s\ \*\/]+)(all|distinct|select)/i', $query, -1, PREG_SPLIT_NO_EMPTY);
               // and then merge the query_parts:
               if (count($query_parts) > 1) {
                   $query = '';
                   foreach($query_parts AS $part) {
                       if ($query != '') $query .= 'UNI0N SELECT'; // a ZERO
                       $query .= $part;
                   }
               }
           }
//            $query = eregi_replace('union','UNI0N', $query); // Old Forced Security issue fix by DJMaze

           $this->query_result = @mysql_query($query, $this->db_connect_id);
           $this->num_queries++;
//            $this->querylist .= $query."<br />";
       }
       if($this->query_result) {
           unset($this->row[$this->query_result]);
           unset($this->rowset[$this->query_result]);
           $this->time += (get_microtime()-$stime);
           $this->query_ids[] = $this->query_result;
           return $this->query_result;
       } else {
           if ($bypass_error) { return NULL; }
           $the_error = "While executing query \"$query\"\n\nthe following error occured: " . mysql_error();
           sqldb_error($the_error, $bypass_error);
       }
   }

   //
   // Other query methods
   //
   function sql_numrows($query_id = 0)
   {
       $stime = get_microtime();
       if(!$query_id) {
           $query_id = $this->query_result;
       }
       if($query_id) {
           $result = @mysql_num_rows($query_id);
           $this->time += (get_microtime()-$stime);
           return $result;
       }
       else {
           $this->time += (get_microtime()-$stime);
           return false;
       }
   }
   function sql_affectedrows()
   {
       $stime = get_microtime();
       if($this->db_connect_id) {
           $result = @mysql_affected_rows($this->db_connect_id);
           $this->time += (get_microtime()-$stime);
           return $result;
       }
       else {
           return false;
       }
   }
   function sql_numfields($query_id = 0)
   {
       $stime = get_microtime();
       if(!$query_id) {
           $query_id = $this->query_result;
       }
       if($query_id) {
           $result = @mysql_num_fields($query_id);
           $this->time += (get_microtime()-$stime);
           return $result;
       }
       else {
           $this->time += (get_microtime()-$stime);
           return false;
       }
   }
   function sql_fieldname($offset, $query_id = 0)
   {
       $stime = get_microtime();
       if(!$query_id) {
           $query_id = $this->query_result;
       }
       if($query_id) {
           $result = @mysql_field_name($query_id, $offset);
           $this->time += (get_microtime()-$stime);
           return $result;
       }
       else {
           $this->time += (get_microtime()-$stime);
           return false;
       }
   }
   function sql_fieldtype($offset, $query_id = 0)
   {
       $stime = get_microtime();
       if(!$query_id) {
           $query_id = $this->query_result;
       }
       if($query_id) {
           $result = @mysql_field_type($query_id, $offset);
           $this->time += (get_microtime()-$stime);
           return $result;
       }
       else {
           $this->time += (get_microtime()-$stime);
           return false;
       }
   }
   function sql_fetchrow($query_id = 0)
   {
       $stime = get_microtime();
       if(!$query_id) {
           $query_id = $this->query_result;
       }
       if($query_id) {
           $this->row[$query_id] = @mysql_fetch_array($query_id);
           $this->time += (get_microtime()-$stime);
           return $this->row[$query_id];
       }
       else {
           $this->time += (get_microtime()-$stime);
           return false;
       }
   }
   function sql_fetchrowset($query_id = 0)
   {
       if(!$query_id)
       {
           $query_id = $this->query_result;
       }
       if($query_id)
       {
           $stime = get_microtime();
           unset($this->rowset[$query_id]);
           unset($this->row[$query_id]);
           while($this->rowset[$query_id] = @mysql_fetch_array($query_id)) {
               $result[] = $this->rowset[$query_id];
           }
           $this->time += (get_microtime()-$stime);
           return $result;
       } else {
           return false;
       }
   }
   function sql_fetchfield($field, $rownum = -1, $query_id = 0)
   {
       if(!$query_id)
       {
           $query_id = $this->query_result;
       }
       if($query_id)
       {
           if($rownum > -1)
           {
               $result = @mysql_result($query_id, $rownum, $field);
           }
           else
           {
               if(empty($this->row[$query_id]) && empty($this->rowset[$query_id]))
               {
                   if($this->sql_fetchrow())
                   {
                       $result = $this->row[$query_id][$field];
                   }
               }
               else
               {
                   if($this->rowset[$query_id])
                   {
                       $result = $this->rowset[$query_id][$field];
                   }
                   else if($this->row[$query_id])
                   {
                       $result = $this->row[$query_id][$field];
                   }
               }
           }
           return $result;
       }
       else
       {
           return false;
       }
   }
   function sql_rowseek($rownum, $query_id = 0){
       if(!$query_id)
       {
           $query_id = $this->query_result;
       }
       if($query_id)
       {
           $result = @mysql_data_seek($query_id, $rownum);
           return $result;
       }
       else
       {
           return false;
       }
   }
   function sql_nextid(){
       if($this->db_connect_id)
       {
           $result = @mysql_insert_id($this->db_connect_id);
           return $result;
       }
       else
       {
           return false;
       }
   }
   function sql_freeresult($query_id = 0){
       if(!$query_id)
       {
           $query_id = $this->query_result;
       }

       if ( $query_id )
       {
           unset($this->row[$query_id]);
           unset($this->rowset[$query_id]);
           @mysql_free_result($query_id);
           $numid = count($this->query_ids);
           for ($i=0; $i<$numid; $i++) {
               if ($this->query_ids[$i] == $query_id) {
                   unset($this->query_ids[$i]);
                   return true;
               }
           }
           return true;
       }
       else
       {
           return false;
       }
   }
   function sql_error($query_id = 0)
   {
       $result["message"] = @mysql_error($this->db_connect_id);
       $result["code"] = @mysql_errno($this->db_connect_id);

       return $result;
   }

} // class sql_db

} // if ... define

?>

 

To zend mou lei Undefined variable: inside_mod stin grammi 47

alla distihos ime newbie kai den katalaveno...

vasika thelo na kano kati install kai afto ine ena include

db.php kai den mou ftiahnei tin DB.

Sas efharisto ek twn proterwn....:-D

Συνδέστε για να σχολιάσετε
Κοινοποίηση σε άλλες σελίδες

Αρχειοθετημένο

Αυτό το θέμα έχει αρχειοθετηθεί και είναι κλειστό για περαιτέρω απαντήσεις.

  • Δημιουργία νέου...

Χρησιμοποιούμε  cookies για να απολαμβάνεις το insomnia προσωποποιημένο στις ανάγκες σου αλλά και για την παροχή στοιχείων επισκεψιμότητας για να βελτιώσουμε την ποιότητα των υπηρεσιών μας