Joomla插件ajax连接,数据库错误
我正在继续我的插件开发传奇。。 所以我已经纠正了我在previuos代码中犯的所有错误-> 现在我想我把一切都做好了,但是db查询不起作用。我不知道这里出了什么问题,db查询对我来说很好Joomla插件ajax连接,数据库错误,ajax,plugins,joomla,Ajax,Plugins,Joomla,我正在继续我的插件开发传奇。。 所以我已经纠正了我在previuos代码中犯的所有错误-> 现在我想我把一切都做好了,但是db查询不起作用。我不知道这里出了什么问题,db查询对我来说很好 <?php // Set flag that this is a parent file define('_JEXEC', 1); // No direct access. defined('_JEXEC') or die; define( 'DS', DIRECTORY_SEPARATOR );
<?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
}
总计)
试试这个……它对我有用
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();
是什么让您认为db查询不起作用?您是否收到任何错误消息。尝试在$db->query($query)之后打印$db,以获取有关该问题的更多详细信息。我将获得输出(或死亡)“blogai”输出。我必须把打印的$db代码放在哪里。在查询之后它不会工作,我想是因为输出“blogai”在文件define('JPATH_BASE',dirname('uuuu file_uu).DS.'''.''.'.'.''.'.''.DS.'.'.'''.DS.''.'.''.'''.DS.'.'.'.'.'.'''.''''.'代码>。这似乎是个问题…请给出正确的DS计数…您可以发布您的文件夹路径吗?