Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in D:\web\testclass\class_mysql.php on line 24
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\web\testclass\class_mysql.php on line 27
PHP Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in D:\web\testclass\class_mysql.php on line 24 PHP Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\web\testclass\class_mysql.php on line 27
Code:
<?php
error_reporting(E_ALL);
class mysql
{
var $oKonekcija='';
var $oResult='';
var $aNiz='';
function db_connect($host, $username, $password)
{
$this->oKonekcija=mysql_connect($host='', $username='', $password='', $db='');
mysql_select_db($db, $this->oKonekcija);
return True;
}
function db_query($query)
{
$this->oResult=mysql_query($query, $this->oKonekcija);
return True;
}
function result2array()
{
if(mysql_num_rows($this->oResult)!=='0')
{
$i=0;
while($aSlog=mysql_fetch_array($this->oResult))
{
$this->aNiz[$i]['Naziv']=$aSlog['MailingEmailAdress'];
$i++;
}
return $this->aNiz;
}
else
{
return False;
}
}
}
$veza=new mysql;
$veza->db_connect("localhost", "root", "", "test");
$veza->db_query("select * from mailinglista");
$niz=$veza->result2array();
for ($i=0; $i<5; $i++)
{
echo $niz[$i]['Naziv'];
}
?>
<?php
error_reporting(E_ALL);
class mysql
{
var $oKonekcija='';
var $oResult='';
var $aNiz='';
function db_connect($host, $username, $password)
{
$this->oKonekcija=mysql_connect($host='', $username='', $password='', $db='');
mysql_select_db($db, $this->oKonekcija);
return True;
}
function db_query($query)
{
$this->oResult=mysql_query($query, $this->oKonekcija);
return True;
}
function result2array()
{
if(mysql_num_rows($this->oResult)!=='0')
{
$i=0;
while($aSlog=mysql_fetch_array($this->oResult))
{
$this->aNiz[$i]['Naziv']=$aSlog['MailingEmailAdress'];
$i++;
}
return $this->aNiz;
}
else
{
return False;
}
}
}
$veza=new mysql;
$veza->db_connect("localhost", "root", "", "test");
$veza->db_query("select * from mailinglista");
$niz=$veza->result2array();
for ($i=0; $i<5; $i++)
{
echo $niz[$i]['Naziv'];
}
?>