udjamaflip
12-17-2008, 04:25 PM
Hi guys, I have the class below and have this error:
Fatal error: Call to undefined function: getattachments()
If I note out the line using the function the page loads but obviously the function doesn't work thats using it, is there something I need to do to use a function within the same class as the function calling it?
class contentDisplay {
function getArticle($id = 'first', $catId)
{
if ($id = 'first')
{
$this->sql = 'SELECT * FROM jos_content WHERE catID='.$catId.' ORDER BY ordering';
}
else
{
$this->sql = 'SELECT * FROM jos_content WHERE catID='.$catId.' AND id='.$id.' LIMIT 1';
}
$this->query = mysql_query($this->sql);
$i = 0;
while ($row = mysql_fetch_array($this->query))
{
if ($i = 0)
{
$this->content['title'] = $row['title'];
$this->content['introtext'] = $row['introtext'];
$this->content['fulltext'] = $row['fulltext'];
$cat = getCategoryInfo($id);
$this->content['subnav'] = '<li><a href="'.$cat['alias'].'/'.$row['id'].'-'.$row['alias'].'.html" title="'.$cat['title'].'">'.$cat['title'].'</a></li>';
}
else
{
$cat = getCategoryInfo($id);
$this->content['subnav'] = '<li><a href="'.$cat['alias'].'/'.$row['id'].'-'.$row['alias'].'.html" title="'.$cat['title'].'">'.$cat['title'].'</a></li>';
}
$i++;
}
$this->content['image'] = getAttachments($row['id']);
return $this->content;
}
function getCategoryInfo($id)
{
$this->sql = 'SELECT * FROM jos_categories WHERE id='.$id.' LIMIT 1';
$this->query = mysql_query($this->sql);
$row = mysql_fetch_array($this->query);
$this->content['title'] = $row['title'];
$this->content['alias'] = $row['alias'];
return $this->content;
}
function getAttachments($id, $limit = 1)
{
$this->sql = 'SELECT * FROM jos_attachments WHERE article_id='.$row['id'].' AND file_type LIKE "%image%" LIMIT '. $limit;
$this->query = mysql_query($this->sql) or die ('failed: '. mysql_error());
$row = mysql_fetch_array($this->query);
if (mysql_num_rows($this->query))
{
$this->content['image'] = '<img src="'.$row['url'].'" alt="'.$row['display_filename'].'" title="'.$row['display_filename'].'" width="330px" />';
}
else
{
$this->content['image'] = 'No Image available.';
}
return $this->content['image'];
}
}
Thanks,
Andy
Fatal error: Call to undefined function: getattachments()
If I note out the line using the function the page loads but obviously the function doesn't work thats using it, is there something I need to do to use a function within the same class as the function calling it?
class contentDisplay {
function getArticle($id = 'first', $catId)
{
if ($id = 'first')
{
$this->sql = 'SELECT * FROM jos_content WHERE catID='.$catId.' ORDER BY ordering';
}
else
{
$this->sql = 'SELECT * FROM jos_content WHERE catID='.$catId.' AND id='.$id.' LIMIT 1';
}
$this->query = mysql_query($this->sql);
$i = 0;
while ($row = mysql_fetch_array($this->query))
{
if ($i = 0)
{
$this->content['title'] = $row['title'];
$this->content['introtext'] = $row['introtext'];
$this->content['fulltext'] = $row['fulltext'];
$cat = getCategoryInfo($id);
$this->content['subnav'] = '<li><a href="'.$cat['alias'].'/'.$row['id'].'-'.$row['alias'].'.html" title="'.$cat['title'].'">'.$cat['title'].'</a></li>';
}
else
{
$cat = getCategoryInfo($id);
$this->content['subnav'] = '<li><a href="'.$cat['alias'].'/'.$row['id'].'-'.$row['alias'].'.html" title="'.$cat['title'].'">'.$cat['title'].'</a></li>';
}
$i++;
}
$this->content['image'] = getAttachments($row['id']);
return $this->content;
}
function getCategoryInfo($id)
{
$this->sql = 'SELECT * FROM jos_categories WHERE id='.$id.' LIMIT 1';
$this->query = mysql_query($this->sql);
$row = mysql_fetch_array($this->query);
$this->content['title'] = $row['title'];
$this->content['alias'] = $row['alias'];
return $this->content;
}
function getAttachments($id, $limit = 1)
{
$this->sql = 'SELECT * FROM jos_attachments WHERE article_id='.$row['id'].' AND file_type LIKE "%image%" LIMIT '. $limit;
$this->query = mysql_query($this->sql) or die ('failed: '. mysql_error());
$row = mysql_fetch_array($this->query);
if (mysql_num_rows($this->query))
{
$this->content['image'] = '<img src="'.$row['url'].'" alt="'.$row['display_filename'].'" title="'.$row['display_filename'].'" width="330px" />';
}
else
{
$this->content['image'] = 'No Image available.';
}
return $this->content['image'];
}
}
Thanks,
Andy