<?
class DB_Sql {
var $Hostname = "localhost";
var $Database = "";
var $Username = "";
var $Pass_data = "";
var $Link_ID = 0
var $Query_ID = 0;
var $Record = array();
var $Row;
var $Errno = 0
var $Error = "";
function halt($msg) {
printf("</td></tr></table><b>Database error:</b> %s<br>\n", $msg);
printf("<b>MySQL Error</b>: %s (%s)<br>\n",
$this->Errno,
$this->Error);
die("Session halted.");
}//end halt
function connect() {
if ( 0 == $this->Link_ID ) {
$this->Link_ID=mysql_connect($this->Hostname, $this->Username, $this->Pass_data);
if (!$this->Link_ID) {
$this->halt("Link-ID == false, connect failed");
}
if (!mysql_query(sprintf("use %s",$this->Database),$this->Link_ID)) {
$this->halt("cannot use database ".$this->Database);
}
}
}//end connect
function query($Query_String) {
$this->connect();
// printf("Debug: query = %s<br>\n", $Query_String);
$this->Query_ID = mysql_query($Query_String,$this->Link_ID);
$this->Row = 0;
$this->Errno = mysql_errno();
$this->Error = mysql_error();
if (!$this->Query_ID) {
$this->halt("Invalid SQL: ".$Query_String);
}
return $this->Query_ID;
}
function next_record() {
$this->Record = mysql_fetch_array($this->Query_ID);
$this->Row += 1;
$this->Errno = mysql_errno();
$this->Error = mysql_error();
$stat = is_array($this->Record);
if (!$stat) {
mysql_free_result($this->Query_ID);
$this->Query_ID = 0;
}
return $stat;
}//end next record
function seek($pos) {
$status = mysql_data_seek($this->Query_ID, $pos);
if ($status)
$this->Row = $pos;
return;
}//end seek
function num_rows() {
return mysql_num_rows($this->Query_ID);
}
function num_fields() {
return mysql_num_fields($this->Query_ID);
}
function f($Name) {
return $this->Record[$Name];
}
function p($Name) {
print $this->Record[$Name];
}
function affected_rows() {
return @mysql_affected_rows($this->Link_ID);
}
}//end class
?>
<?
//here is an Example of where my problem is.
$user = new DB_Sql;
$pokebola = new DB_Sql;
$query=" SELECT * FROM foro_users WHERE user='$user' ";
$user->query($query);
$user->next_record();
$aux = $user->Record[user_id];
$query = "SELECT * FROM mundo_pokebola WHERE id_user=$aux";
$pokebola->query($query);
$cant_pokemons = $pokebola->num_rows();
?>
If you see there is an $aux variable because i cant get the $user->Record[user_id]; into the SELECT query. I get a parse error... can someone help please....