0

I am using Joomla 2.5.11 . I have a php file stored in the /public_html/joomtest/components/com_jumi/files which is pasted below. I have a PHP form which is stored in the same location i.e /public_html/joomtest/components/com_jumi/files.

I want the PHP form to call the PHP script so that an article is created in Joomla. But whenever the PHP script is called, I receive the below error

Fatal error: Class 'JTable' not found

and the line on which Joomla throws error is

$table = JTable::getInstance('Content', 'JTable', array());

PHP script

<?php


$table = JTable::getInstance('Content', 'JTable', array());
$data = array(
    'catid' => 8,
    'title' => 'SOME TITLE',
    'introtext' => 'SOME TEXT',
    'fulltext' => 'SOME TEXT',
    'state' => 0,
);


if (!$table->bind($data))
{
    $this->setError($table->getError());
    return false;
}


if (!$table->check())
{
    $this->setError($table->getError());
    return false;
}


if (!$table->store())
{
    $this->setError($table->getError());
    return false;
}
?>

</body>
</html>

I tried putting in

require_once('/libraries/joomla/database/table.php');

but this again didnt work. Please help.

4

1 回答 1

2

您需要定义要使用的表格文件的路径。使用以下代码包含特定表。例如:

JTable::addIncludePath(JPATH_SITE.DS.'components'.DS.'com_content'.DS.'tables'); 

然后像下面这样调用你的表:

$con_table = JTable::getInstance('Content', 'JTable', array());

希望这会奏效。祝你好运。

于 2013-07-08T13:14:12.467 回答