I've been using using Tidy just by enabling its extension in php.ini (in XAMPP, WINDOWS OS)
I'm trying to do the same on XAMPP,macOS by enabling the Tidy extendion in the php.ini which is located in /Applications/XAMPP/xamppfiles/etc/php.ini but I still get php error when i try to instantiate the tidy class:
Fatal error: Uncaught Error: Class "tidy" not found in /Applications/XAMPP/xamppfiles/htdocs/joacmedia/app/core/functions.php:48 Stack trace: #0 /Applications/XAMPP/xamppfiles/htdocs/joacmedia/app/models/user.php(402): truncate('James is a powe...', 200) #1 /Applications/XAMPP/xamppfiles/htdocs/joacmedia/app/views/joacmedia/temp/us.php(237): User->truncate('James is a powe...', 200) #2 /Applications/XAMPP/xamppfiles/htdocs/joacmedia/app/views/joacmedia/temp/us.php(283): Page->sectionIntro(Object(stdClass)) #3 /Applications/XAMPP/xamppfiles/htdocs/joacmedia/app/views/joacmedia/temp/us.php(34): Page->LayoutBottomAream(Object(stdClass)) #4 /Applications/XAMPP/xamppfiles/htdocs/joacmedia/app/views/joacmedia/temp/us.php(355): Page->__construct(Array) #5 /Applications/XAMPP/xamppfiles/htdocs/joacmedia/app/core/controller.php(11): include('/Applications/X...') #6 /Applications/XAMPP/xamppfiles/htdocs/joacmedia/app/views/joacmedia/us.php(5): Controller->view('joacmedia/temp/...', Array) #7 /Applications/XAMPP/xamppfiles/htdocs/joacmedia/app/core/controller.php(11): include('/Applications/X...') #8 /Applications/XAMPP/xamppfiles/htdocs/joacmedia/app/controllers/us.php(47): Controller->view('joacmedia/us', Array) #9 /Applications/XAMPP/xamppfiles/htdocs/joacmedia/app/core/app.php(61): Us->index('jay') #10 /Applications/XAMPP/xamppfiles/htdocs/joacmedia/index.php(6): App->__construct() #11 {main} thrown in /Applications/XAMPP/xamppfiles/htdocs/joacmedia/app/core/functions.php on line 48
what should i do to get this error fixed ?
`
//add ellipsis to string
function truncate($html,$length){
$tidy = new tidy();
if ((int)mb_strlen($html,'UTF-8') >= (int)$length ) {
$ellipsis = "<div class='ellipsis_show'>
<div data-href='false' class='text-right see_more_text text-secondary'><strong>...</strong>see more</div>
</div>";
return trim((strip_empty_tag(convert_ENCODE($tidy->repairString("<span data-show-summary='true'>".(NewLineToBreak(substr(trim($html),0,$length)))."</span>"."<span class='text_exposed_hide hide visually_hidden'>".trim(NewLineToBreak(substr($html,$length)))."</span>"),'UTF-8')))).$ellipsis;
}
return trim((strip_empty_tag(convert_ENCODE(tidy_repair_string(NewLineToBreak($html)),'UTF-8'))));
}
`
You are doing a new tidy() in your function and I suspect you do not have the tiny class defined in the same file or namespace. If you use namespaces you shoud do the use your/namespace/to/tiny or you should do a require/include in your functions.php file to include the desired tiny class file.
Related
when accessing the www.hostname/phpmyadmin/ page i get the blank page. Tried to reinstall PHP,HTTPD and MYSQL.
After running php index.php in the phpmyadmin folder I get the following error:
[root#ansible1 phpmyadmin]# php index.php
PHP Fatal error: Uncaught Error: Call to a member function getCookie() on null in /usr/share/phpmyadmin/libraries/classes/Url.php:219
Stack trace:
#0 /usr/share/phpmyadmin/libraries/classes/Url.php(171): PhpMyAdmin\Url::getCommonRaw(Array, '?')
#1 /usr/share/phpmyadmin/libraries/classes/Core.php(762): PhpMyAdmin\Url::getCommon(Array)
#2 /usr/share/phpmyadmin/libraries/classes/Core.php(338): PhpMyAdmin\Core::linkURL('https://secure....')
#3 /usr/share/phpmyadmin/libraries/classes/Core.php(364): PhpMyAdmin\Core::getPHPDocLink('book.json.php')
#4 /usr/share/phpmyadmin/libraries/classes/Core.php(1006): PhpMyAdmin\Core::warnMissingExtension('json', true)
#5 /usr/share/phpmyadmin/libraries/common.inc.php(110): PhpMyAdmin\Core::checkExtensions()
#6 /usr/share/phpmyadmin/index.php(23): require_once('/usr/share/phpm...')
#7 {main}
thrown in /usr/share/phpmyadmin/libraries/classes/Url.php on line 219
On the line 219 in the corresponding file:
public static function getCommonRaw($params = [], $divider = '?')
{
/** #var Config $PMA_Config */
global $PMA_Config;
$separator = Url::getArgSeparator();
// avoid overwriting when creating navi panel links to servers
if (isset($GLOBALS['server'])
&& $GLOBALS['server'] != $GLOBALS['cfg']['ServerDefault']
&& ! isset($params['server'])
&& ! $PMA_Config->get('is_setup')
) {
$params['server'] = $GLOBALS['server'];
}
if (empty($PMA_Config->getCookie('pma_lang')) && ! empty($GLOBALS['lang'])) {
$params['lang'] = $GLOBALS['lang'];
}
$query = http_build_query($params, '', $separator);
if ($divider != '?' || strlen($query) > 0) {
return $divider . $query;
}
Not sure what I am doing wrong but havent found this error on the internet....
The blowfish secret is set:
$cfg['blowfish_secret'] = 'H2OxcGXxflSd8JwrwVlh6KW6s2rER63i';
Any idea what could I be missing? Even a hint what direction to look will be appreciated.
EDIT1:
Downgraded to version 4.9.4 - getting the similar error:
So after downgrading to version 4.9.4 I get the very similar....
[root#ansible1 phpmyadmin]# php index.php
PHP Fatal error: Uncaught Error: Call to a member function getCookie() on null in /usr/share/phpmyadmin/libraries/classes/Url.php:217
Stack trace:
#0 /usr/share/phpmyadmin/libraries/classes/Url.php(169): PhpMyAdmin\Url::getCommonRaw(Array, '?')
#1 /usr/share/phpmyadmin/libraries/classes/Core.php(749): PhpMyAdmin\Url::getCommon(Array)
#2 /usr/share/phpmyadmin/libraries/classes/Core.php(330): PhpMyAdmin\Core::linkURL('https://secure....')
#3 /usr/share/phpmyadmin/libraries/classes/Core.php(353): PhpMyAdmin\Core::getPHPDocLink('book.json.php')
#4 /usr/share/phpmyadmin/libraries/classes/Core.php(987): PhpMyAdmin\Core::warnMissingExtension('json', true)
#5 /usr/share/phpmyadmin/libraries/common.inc.php(106): PhpMyAdmin\Core::checkExtensions()
#6 /usr/share/phpmyadmin/index.php(27): require_once('/usr/share/phpm...')
#7 {main}
thrown in /usr/share/phpmyadmin/libraries/classes/Url.php on line 217
The page now shows: Access Denied - simply written, no pictures or anything.
What am I missing? :/
[Browser view1
I don't know if my previous post is visible, so I post it again:
I had the same error message, and row #4 says: "PhpMyAdmin\Core::warnMissingExtension('json', true)".
After installing php-json package, problem was solved for me.
I've attempted to extend the Phalcon\Db\Adapter\Pdo\Mysql to create a log every time a query function returns false.
Even though I'm not creating any new connections except the one in parent::__construct I'm getting the following exception:
Fatal error: Uncaught PDOException: SQLSTATE[08004] [1040] Too many connections in ...Internal/Database/Mysql.php:14 Stack trace: #0 [internal function]: PDO->__construct('mysql:adapter=M...', '...', '...', Array) #1 [internal function]: Phalcon\Db\Adapter\Pdo->connect(Array) #2 .../Internal/Database/Mysql.php(14): Phalcon\Db\Adapter\Pdo->__construct(Array) #3 .../apps/bootstrap/app.php(378): Internal\Database\Mysql->__construct(Array) #4 [internal function]: Closure->{closure}() #5 [internal function]: Phalcon\Di\Service->resolve(NULL, Object(Phalcon\Di\FactoryDefault)) #6 .../apps/bootstrap/core_services.php(7): Phalcon\Di->get('logs') #7 [internal function]: Closure->{closure}() #8 [internal function]: Phalcon\Di\Service->resolve(NULL, Object(Phalcon\Di\FactoryDefault)) #9 .../apps/libs/Internal/Database/Mysql.php(15): Phalcon\Di->get('logger') #10 .../apps/bootstrap/app.php(37 in .../apps/libs/Internal/Database/Mysql.php on line 14
Code:
namespace Internal\Database;
use Phalcon\Db\Adapter\Pdo\Mysql as PhalconMysql;
use Phalcon\Di;
class Mysql extends PhalconMysql
{
public $isLogger = false;
public function __construct(array $descriptor)
{
parent::__construct($descriptor);
$this->oLogger = Di::getDefault()->get('logger');
}
public function query($sqlStatement, $bindParams = null, $bindTypes = null)
{
$oResult = parent::query($sqlStatement, $bindParams, $bindTypes);
if ($oResult === false && $this->isLogger === false) {
$trace = debug_backtrace();
$aCaller = array_shift($trace);
$sFile = $aCaller['file'];
$sLine = $aCaller['line'];
$this->oLogger->error('MySQL query failed. File: ' . $sFile . ', Line: ' . $sLine, ['error' => $this->getErrorInfo()]);
}
return $oResult;
}
}
The line that triggers the error is parent::__construct($descriptor);.
The only other change I've made was to replace the usage of Phalcon\Db\Adapter\Pdo\Mysql with Internal\Database\Mysql. All the connections are created in the same way they were when I were using Phalcon\Db\Adapter\Pdo\Mysql.
I've looked at the parent classes of Phalcon\Db\Adapter\Pdo\Mysql. The only place I see the connection created is here
I'd very much appreciate your help with this issue.
It is not a right thing to extend classes in phalcon, that are actually interacting with other php extensions. Learned it the hard way.
The easy way I would recommend is to override Mvc/Model class as a eg. ModelCommon or BaseModel, and implement there Model::initialize and Model::afterFetch.
But a proper way would to be to use event mechanism developed out in Phalcon. The trick is to attach to beforeQuery and/or afterQuery events.
Shortcut for that, done in DI:
$di->set('db', function() use ($di) {
$config = $di->getConfig();
$connection = new \Phalcon\Db\Adapter\Pdo\Mysql([
// ...
]);
$eventsManager->attach('db', function($event, $connection, $params) use ($config) {
if ($event->getType() == 'beforeQuery') {
// ...
}
if ($event->getType() == 'afterQuery') {
// ...
}
});
$connection->setEventsManager($eventsManager);
return $connection;
});
Looks like the module is trying to connect to database more than once. Perhaps make sure you initialise database service just once in your Module.php
Maybe you can db service as shared when you declare db in $di
$di->setShared('db', function() {
// return your db instance
});
Problem solved, although I still don't understand why it occurred in the first place.
The logger logs to the database, but since it's taken from Di I assumed it reuses existing connection. Removing that line from constructor, and putting it right after the logger is called solved the problem.
I have the following PHP code:
try{
$doc = couchDocument::getInstance($db,"document10");
}catch(couchExpention $e){
echo $e->getMessage();
}
However instead of the desired output I get:
PHP Fatal error: Uncaught exception 'couchNotFoundException' with message 'Object Not Found - missing (GET /db/document10[])' in /var/www/public_html/lib/couchClient.php:1012
Stack trace:
#0 /var/www/public_html/lib/couchClient.php(157): couchException::factory(Array, 'GET', '/db/169488e77e2...', Array)
#1 /var/www/public_html/lib/couchClient.php(427): couchClient->_queryAndTest('GET', '/db/169488e77e2...', Array, Array)
#2 /var/www/public_html/lib/couchDocument.php(47): couchClient->getDoc('169488e77e2j385...')
#3 /var/www/public_html/lib/couchDocument.php(102): couchDocument->load('169488e77e2j385...')
#4 /var/www/public_html/index.php(8): couchDocument::getInstance(Object(couchClient), '169488e77e2j385...')
#5 {main}
thrown in /var/www/public_html/lib/couchClient.php on line 1012
You code is trying to catch a couchExpention instead of a couchException
I need to verify the existence of a method in a controller from a model with codeigniter 2.0.2. and HMVC.
I'm trying to do with ReflectionClass:hasMethod(), without success.
My code in Model:
function hasPanel($controller){
$rc = new ReflectionClass($controller);
if($rc::hasMethod("panel_base")){
return true;
}
return false;
}
And the unwelcome error:
Fatal error: Uncaught exception 'ReflectionException' with message 'Class administracion does not exist' in D:\xampp\htdocs\sea\application\models\auth\permisos.php:368
Stack trace:
#0 D:\xampp\htdocs\sea\application\models\auth\permisos.php(368): ReflectionClass->__construct('administracion')
#1 D:\xampp\htdocs\sea\application\models\auth\permisos.php(357): Permisos->hasPanel('administracion')
#2 D:\xampp\htdocs\sea\application\controllers\auth\identificar.php(101): Permisos->getControladores('administracion')
#3 [internal function]: Identificar->modulo()
#4 D:\xampp\htdocs\sea\application\core\Admin_controller.php(317): call_user_func_array(Array, Array)
#5 D:\xampp\htdocs\sea\system\core\CodeIgniter.php(305): Admin_controller->_remap('modulo', Array)
#6 D:\xampp\htdocs\sea\www\index.php(252): require_once('D:\xampp\htdocs...')
#7 {main}
thrown in D:\xampp\htdocs\sea\application\models\auth\permisos.php on line 368
EDITED
This solves the above...
function hasPanel($controller,$route){
include_once($route);
$rc = new ReflectionClass($controller);
if($rc::hasMethod("panel_base")){
return true;
}
return false;
}
But causes this:
Fatal error: Non-static method ReflectionClass::hasMethod() cannot be called statically, assuming $this from incompatible context in D:\xampp\htdocs\sea\application\models\auth\permisos.php on line 373
Some idea?
I'm not entirely sure, but this might be as simple as $rc->hasMethod("panel_base"); You did instantiate a new class. . .
Change
$rc::hasMethod("panel_base")
to
$rc->hasMethod("panel_base")
I using Zend Gdata library for search video Youtube API.
If I make a bad request, then a zend exception..
Example:
Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' in D:\Webserver\domains\loc\controller\Zend\Gdata\App.php:710
Stack trace:
#0 D:\Webserver\domains\loc\controller\Zend\Gdata.php(221): Zend_Gdata_App->performHttpRequest('GET', 'http://gdata.yo...', Array, NULL, NULL, NULL)
#1 D:\Webserver\domains\loc\controller\Zend\Gdata\App.php(876): Zend_Gdata->performHttpRequest('GET', 'http://gdata.yo...', Array)
#2 D:\Webserver\domains\loc\controller\Zend\Gdata\App.php(764): Zend_Gdata_App->get('http://gdata.yo...', NULL)
#3 D:\Webserver\domains\loc\controller\Zend\Gdata\App.php(220): Zend_Gdata_App->importUrl('http://gdata.yo...', 'Zend_Gdata_YouT...', NULL)
#4 D:\Webserver\domains\loc\controller\Zend\Gdata.php(187): Zend_Gdata_App->getEntry('http://gdata.yo...', 'Zend_Gdata_YouT...')
#5 D:\Webserver\domains\loc\controller\Zend\Gdata\YouTube.php(293): Zend_Gdata->getEntry('http://gdata.yo...', 'Zend_Gdata_YouT...')
#6 D:\Webserver\domains\loc\controller\Yo in D:\Webserver\domains\loc\controller\Zend\Gdata\App.php on line 710
But I do not want users of my site have seen this error ... I need to catch this error and cause no Exception and just want to get the text of the error .. What should I do?
Put the code that causes the exception into a try/catch statement
try {
// code calling Zend_Gdata_App->performHttpRequest
} catch(Zend_Gdata_App_HttpException $e) {
$message = $e->getMessage();
// do something with $message now
}
More information: http://de3.php.net/manual/en/language.exceptions.php