PHP:
<?php
require("class.database.php");
class Item extends Database{
private $_iID;
private $_OwnerID;
private $_window;
private $_pos;
private $_count;
private $_vnum;
private $_socket0;
private $_socket1;
private $_socket2;
private $_socket3;
private $_socket4;
private $_socket5;
private $_attrtype0;
private $_attrtype1;
private $_attrtype2;
private $_attrtype3;
private $_attrtype4;
private $_attrtype5;
private $_attrtype6;
private $_attrvalue0;
private $_attrvalue1;
private $_attrvalue2;
private $_attrvalue3;
private $_attrvalue4;
private $_attrvalue5;
private $_attrvalue6;
public function __contruct($iID) <-- line 34
{
parent::__construct("host", "root"," pass") ;
parent::_connect();
parent::_ChangeDB("player");
try{
$SQL=mysql_query("SELECT * FROM item WHERE id='$iID'");
if (!$SQL){throw new exception ("query fallita");}else{
$data=mysql_fetch_array($SQL);
$this->_iID = $iID;
$this->_OwnerID = $data[1];
$this->_window = $data[2];
$this->_pos = $data[3];
$this->_count = $data[4];
$this->_vnum = $data[5];
$this->_socket0 = $data[6];
$this->_socket1 = $data[7];
$this->_socket2 = $data[8];
$this->_socket3 = $data[9];
$this->_socket4 = $data[10];
$this->_socket5 = $data[11];
$this->_attrtype0 = $data[12];
$this->_attrtype1 = $data[13];
$this->_attrtype2 = $data[14];
$this->_attrtype3 = $data[15];
$this->_attrtype4 = $data[16];
$this->_attrtype5 = $data[17];
$this->_attrtype6 = $data[18];
$this->_attrvalue0 = $data[19];
$this->_attrvalue1 = $data[20];
$this->_attrvalue2 = $data[21];
$this->_attrvalue3 = $data[22];
$this->_attrvalue4 = $data[23];
$this->_attrvalue5 = $data[24];
$this->_attrvalue6 = $data[25];
$arrayprop = array("OwnerID" => $this->_OwnerID, "Window" => $this->_window, "Pos"=>$this->_pos,
"Count" => $this->_count,"Vnum"=>$this->_vnum,"socket0"=>$this->_socket0,"socket1"=>$this->_socket2,
"socket3"=>$this->_socket3,"socket4"=>$this->_socket4,"socket5"=>$this->_socket5,"socket6"=>$this->_socket6,
"attrtype0"=>$this->_attrtype0,"attrtype1"=>$this->_attrtype1,"attrtype2"=>$this->_attrtype2,
"attrtype3"=>$this->_attrtype3,"attrtype4"=>$this->_attrtype4,"attrtype5"=>$this->_attrtype5,
"attrtype6"=>$this->_attrtype6,"attrvalue0"=>$this->_attrvalue0,"attrvalue1"=>$this->_attrvalue1,
"attrvalue2"=>$this->_attrvalue2,"attrvalue3"=>$this->_attrvalue3,"attrvalue4"=>$this->_attrvalue4,
"attrvalue5"=>$this->_attrvalue5,"attrvalue6"=>$this->_attrvalue6);
return $arrayprop;
}
catch (Exception $e){echo $e->getMessage()};
}
}
}
Codice:
errore: (Parse error: syntax error, unexpected T_GLOBAL, expecting T_STRING in class.item.php on line 34)
Chi mi sa spiegare perchè? la riga 34 è quella =)
devo soltanto prendere delle informazioni da DB e inserirle nell'array...se avete altri metodi più validi e veloci sono tutto orecchi!
Ecco la classe parente, aiutatemi anche in questo per favore , sono novellino.
PHP:
?php
class Database {
private $_conn;
private $_login;
private $_database;
private $_password;
private $_port;
private $_timeout;
private $_host;
public $_query;
public function __construct($host,$login,$pass)
{
if(isset($login)){$this->_login = $login;}else{$error="Manca il login <br>";};
if(isset($pass)){$this->_password = $pass;}else{$error.="Manca la password <br>";};
if(isset($host)){$this->_host = $host;}else{$error.="Manca l'host";};
return $error;
}
Public function _Connect(){
$this->_conn = mysql_connect($this->_host,$this->_login,$this->_password);
if (!$this->_conn)
{throw new exception
("Impossibile connettersi al Database: host '$this->_host' user: '$this->_login' pass: '$this->_password' ");}
return $this->_conn;
}
Public function _ConnectToDB($DB){
$this->_database=$DB;
if(isset($login)){
$this->_conn = mysql_connect($this->_host,$this->_login,$this->_password,$this->_database);
if (!$this->_conn){throw new exception ("impossibile connettersi al database o al Database desiderato.");};
}else{$error.="Manca il database"; return $error;};
}
Public function _ChangeDB($DB){
$this->_database = $DB;
mysql_select_db($DB,$this->_conn);
}
public function setConn($login,$pass,$host,$DB){
if(isset($login)){$this->_login = $login;}else{$error="Manca il login <br>";};
if(isset($login)){$this->_password = $password;}else{$error.="Manca la password <br>";};
if(isset($login)){$this->_host = $host;}else{$error.="Manca l'host";};
if(isset($login)){$this->_database = $DB;};
return $error;
}
//Public function _destruct{}
Public function _execQuery($query){
$this->_Connect();
$this->_ChangeDB($this->_database);
$this->_query = mysql_query($query);
return $this->_query;
}
Public function _GetQuery(){
return $this->_query;
}
Public function _GetNumRows(){
$num= mysql_num_rows($this->_query);
return $num;
}
public function _affect_assoc(){
return mysql_fetch_assoc($this->_query); }
}
?>