<?php
define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(__FILE__).'/..' );
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
$mainframe = JFactory::getApplication('site');
date_default_timezone_set('Asia/Kolkata');
$catid1 = urldecode($_POST['catid1']) ;
$catid2 = urldecode($_POST['catid2']) ;
$sql = "SELECT `id` , `title` , `introtext` , `created` FROM `goqc9w_content` WHERE ( `catid` = $catid1 OR `catid` = $catid2 ) AND `created` >= DATE_SUB(CURDATE(), INTERVAL 1 DAY) ORDER BY `created` DESC" ;
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$db->setQuery($sql);
$results = $db -> loadAssocList();
echo "Echo<br>" ;
if(count($results) > 0) {
$json = array() ;
$i = 0 ;
while($i < count($results)) {
$results[$i]['title'] = mb_convert_encoding($results[$i]['title'] , "UTF-8") ;
$results[$i]['img_src'] = (string) reset(simplexml_import_dom(DOMDocument::loadHTML($results[$i]['introtext']))->xpath("//img/@src")) ;
$results[$i]['introtext'] = mb_convert_encoding($results[$i]['introtext'] , "UTF-8") ;
$json[] = $results[$i] ;
$i = $i + 1 ;
echo "Inside loop<br>" ;
}
echo "Outside loop<br>" ;
print json_encode($json) ;
} else {
echo "0" ;
}?>
我必须从我的Joomla数据库的goqc9w_content
表中获取数据。在更改服务器的IP之前,PHP代码上面工作正常。但是在更改服务器的IP之后,它无法正常工作,并且没有从数据库中获取数据。
感兴趣的是它既不执行IF块的语句(if(count($ results)&gt; 0))也不执行ELSE块的语句。它只打印“Echo”,没有显示其他错误。
所以请帮助我。