0

我正在继续我的插件开发传奇.. 所以我已经纠正了我在 previuos 代码中犯的所有错误 ->使用 joomla 方法会阻止文件在插件中工作

现在我认为我做的一切都很好,但是数据库查询不起作用。我不知道这里出了什么问题,数据库查询对我来说看起来不错

<?php
// Set flag that this is a parent file
define('_JEXEC', 1);

// No direct access.
defined('_JEXEC') or die;

define( 'DS', DIRECTORY_SEPARATOR );

define('JPATH_BASE', dirname(__FILE__).DS.'..'.DS.'..'.DS.'..'.DS.'..' );

require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
jimport( 'joomla.database.database' );


$db = JFactory::getDbo();

if(JRequest::getInt('id'))
{

$id = JRequest::getInt('id');
$name = JRequest::getVar('name');

$query = "update #__messages set $name=$name+1 where id='$id'";
$db->setQuery( $query );
$db->query( $query ) or die('blogai');


?>
<div style="margin-bottom:10px">
<b>Ratings for this blog</b> ( <?php echo $total; ?> total)
</div>
<table width="700px">

<tr>
<td width="30px"></td>
<td width="60px"><?php echo $up_value; ?></td>
<td width="600px"><div id="greebar" style="width:<?php echo $up_per; ?>%"></div></td>
</tr>

<tr>
<td width="30px"></td>
<td width="60px"><?php echo $down_value; ?></td>
<td width="600px"><div id="redbar" style="width:<?php echo $down_per; ?>%"></div></td>
</tr>

</table>

<?php

}
4

1 回答 1

0

试试这个..它对我有用

define( '_JEXEC', 1 );
chdir("../../");
getcwd();
define('JPATH_BASE', getcwd() );

define( 'DS', DIRECTORY_SEPARATOR );

require_once (JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );

global $mainframe;

$mainframe =& JFactory::getApplication('site');
$mainframe->initialise();

$db         =  JFactory::getDBO();
于 2012-09-18T03:54:31.837 回答