[ picos_f @ 24.01.2010. 19:51 ] @
Kada pokrene ovaj kod (ovde nije dat ceo kod) dobijem gresku "The configuration did not recieve appropriate variables to accept your request." Ako neko moze da mi pomogne bio bih puno zahvalan

Code:
<?php
/*

*/
define("CALC_PERIOD",24*60*60);
class DBConnect
{
private $link=null;
private $db=null;
private $result=null;
private $primareyKeyField="userid";
private $dbtables=null;
private $dbfields=null;

function DBConnect($userid=" ----datebase user here---",$password="",$host="---- host name Here-----") ========>edit here host datebase user
{
$this->link=mysql_connect($host, $userid, $password) or die(mysql_error());
}
function setDatabase($db)
{
$this->db=$db;
mysql_select_db($this->db, $this->link) or die(mysql_error());
$tableSql="show tables from `".$this->db."`";
$res=mysql_query($tableSql, $this->link) or die(mysql_error());
while($row=mysql_fetch_row($res))
{
$this->dbtables[]=$row[0];
}
foreach($this->dbtables as $ind=>$table)
{
$defaultValueSql="show fields from `".$this->db."`.`".$table."`";
$res=mysql_query($defaultValueSql, $this->link) or die(mysql_error());
while($row=mysql_fetch_assoc($res))
{
$fldname=$row["Field"];
unset($row["Field"]);
$this->dbfields[$table][$fldname]=$row;
}
}
}
[ bogdan.kecman @ 24.01.2010. 21:14 ] @
gde ti prijavi tu gresku? u kojoj liniji ?

ako pravis klasu - onda nemoj da koristis "or die(..." vec napravi da funkcija vrati gresku, postavi status klase etc .. a ne samo da pukne

show xyz u mysql-u nije normalan query. standardno show ovo ono neces videtiu kao rezultat posle normalnog mysql_connect (morao bi da budzis tu neke flegove). imas bazu "information_schema" u kojoj imas sve informacije koje ti trebaju a koje mozes da dobijes sa normalnim SELECT ovo ono ..
[ picos_f @ 24.01.2010. 21:23 ] @
Znaci kada otvorim fajl preko browser-a nece da uradi nista, samo pokaze poruku "The configuration did not recieve appropriate variables to accept your request". Ovaj fajl bi koristio za cronjob. Znaci posle ovog koda sto sam postavio slede neke funkcije koje treba da se odrade, odnosno update-uju neke podatke u bazi.
[ picos_f @ 24.01.2010. 21:28 ] @
Jel bi mogao da mi ispravis samo ovaj deo sto sam postavio, ako nije problem.
[ bogdan.kecman @ 25.01.2010. 06:50 ] @
ovo nije bas php forum (ima i takav), a i ako oces da koristis klase onda bolje koristi mysqli connector u php-u .. al evo ti ..

Code:


<?php
define("CALC_PERIOD",24*60*60);

class DBConnect {
  private $link=null;
  private $db=null;
  private $result=null;
  private $primareyKeyField="userid";
  private $dbtables=null;
  private $dbfields=null;

  private $connected=0;
  private $error="";

  function DBConnect($userid=" ----datebase user here---",$password="",$host="---- host name Here-----"){
    $this->link=mysql_connect($host, $userid, $password);
    if (!$this->link){
       $this->error = mysql_error();
       $this->connected = 0;
    } else {
       $this->connected = 1;
    }
    return $this->connected;
  } // DBConnect
   
  function setDatabase($db){
    $this->db=$db;
    $res = mysql_select_db($this->db, $this->link);
    if (!$res){
       $this->error = mysql_error();
       $this->db = null;
       $selected = 0;
    } else {
       $selected = 1;
       $q = mysql_query("SELECT `table_name` FROM `INFORMATION_SCHEMA`.`TABLES` WHERE `TABLE_SCHEMA`='$db'", $this->link);
       while ($row = mysql_fetch_row($q)) $this->dbtables[]=$row[0];
       @mysql_free_result($q);

       $q = mysql_query("SELECT `TABLE_NAME`, `COLUMN_NAME` FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE `TABLE_SCHEMA`='$db'", $this->link);
       while ($row = mysql_fetch_assoc($q)) $this->dbfields[$row['TABLE_NAME']][]=$row['COLUMN_NAME'];
       @mysql_free_result($q);
    }
    return $selected;
  } // setDatabase

} //class
?>