简体   繁体   中英

Class 'JTable' not found

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 ie /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.

You need to define path of table file you want to use. Use the following code for include the specific table. For example:

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

And then call your table like below:

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

Hope this will work. Good Luck.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM