Undefined class constant fix [duplicate] - php

This question already has answers here:
Reference - What does this error mean in PHP?
(38 answers)
Closed 3 years ago.
I'm coding a website in php but when I tested it, the page indicates HTTP ERROR 500. So I searched for the problem and I found a log file which indicated me the following content:
'ERR_WARNING' in /Applications/MAMP/htdocs/SITE/config/connect.php:3
Stack trace:
#0 /Applications/MAMP/htdocs/SITE/config/functions.php(5): require()
#1 /Applications/MAMP/htdocs/SITE/index.php(4): getArticles()
#2 {main} thrown in /Applications/MAMP/htdocs/SITE/config/connect.php on line 3
Then I checked the file functions.php but found no errors could you please help me fix this problem.
Here is my functions.php file:
<?php
// ARTICLE FUNCTION
function getArticles()
{
require "./config/connect.php";
$req = $bdd->prepare('SELECT id, title FROM articles ORDER BY id DESC');
$req->execute();
$data = $req->fetchAll(PDO::FETCH_OBJ);
return $data;
$req->closeCursor();
}
?>
Here is my connect.php file:
<?php
$bdd = new PDO('mysql:host=localhost;dbname=blog;charset=utf8','root','root');
$bdd->setAttribute(PDO::ATTR_ERRMODE, PDO::ERR_WARNING);
?>
Then, I placed the replace command in function.php under the close cursor one, however, it didn't solve the problem
Then, I changed the password in my connect file and in my database so that they are now the same one.
But it didn't solve the problem showing me the following message:
[09-Apr-2019 15:15:31 UTC] PHP Fatal error: Uncaught PDOException: SQLSTATE[HY000] [1045] Access denied for user 'root'#'localhost' (using password: >YES) in /Applications/MAMP/htdocs/SITE/config/connect.php:2
Stack trace:
#0 /Applications/MAMP/htdocs/SITE/config/connect.php(2): PDO->__construct('mysql:host=loca...', 'root', '123')
#1 /Applications/MAMP/htdocs/SITE/config/functions.php(5): require('/Applications/M...')
#2 /Applications/MAMP/htdocs/SITE/index.php(4): getArticles()
#3 {main}
thrown in /Applications/MAMP/htdocs/SITE/config/connect.php on line 2
Then, I realised that the password I put in the connect file was wrong and I changed it. It took me back to the first error:
[09-Apr-2019 16:40:18 UTC] PHP Fatal error: Uncaught Error: Undefined class constant 'ERR_WARNING' in /Applications/MAMP/htdocs/SITE/config/connect.php:3
Stack trace:
#0 /Applications/MAMP/htdocs/SITE/config/functions.php(5): require()
#1 /Applications/MAMP/htdocs/SITE/index.php(4): getArticles()
#2 {main}
thrown in /Applications/MAMP/htdocs/SITE/config/connect.php on line 3

I finally found the solution.
In the connect file my line 3 was:
$bdd->setAttribute(PDO::ATTR_ERRMODE, PDO::ERR_WARNING);
However there was a typo: constant ERR_WARNING doesn't exist – it should be: ERRMODE_WARNING. Replacing that constant with the correct name fixed the problem:
$bdd->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
Thank you for all your answers and excuse to have bothered your time for this simple problem

Related

Fatal error: Class 'Document' not found in C:\xampp\htdocs\test.php:4 Stack trace: #0 {main} thrown in C:\xampp\htdocs\test.php on line 4

I want to make test.php can convert input1.pdf become docx file, but igot this error
Fatal error: Class 'Document' not found in C:\xampp\htdocs\test.php:4 Stack trace: #0 {main} thrown in C:\xampp\htdocs\test.php on line 4
test.php full code
<?php
# Open the target document
$pdf = new Document($dataDir . 'input1.pdf');
# Save the concatenated output file (the target document)
$pdf->save($dataDir . "output.docx");
print "Document has been converted successfully";
?>
may somone help me? thanks

WPForms Lite error: Uncaught RuntimeException: Extraction failed: variable names are clashing with the existing ones

WPForms Lite has caused a fatal error on my WordPress page, and I struggle with figuring out what the problem is and how to fix it.
Error Details:
An error of type E_ERROR was caused in line 106 of the file /home/pagename/public_html/wp-content/plugins/wpforms-lite/src/Helpers/Templates.php. Error message: Uncaught RuntimeException: Extraction failed: variable names are clashing with the existing ones. in /home/pagename/public_html/wp-content/plugins/wpforms-lite/src/Helpers/Templates.php:106
It seems like the function is supposed to include a template, and the error exists to "protect the scope from modification".
Stack trace:
#0 /home/pagename/public_html/wp-content/plugins/wpforms-lite/src/Helpers/Templates.php(127): WPForms\Helpers\Templates::include_html('education/admin...', Array, true)
#1 /home/pagename/public_html/wp-content/plugins/wpforms-lite/includes/functions.php(2402): WPForms\Helpers\Templates::get_html('education/admin...', Array, true)
#2 /home/pagename/public_html/wp-content/plugins/wpforms-lite/src/Lite/Admin/Education/Admin/NoticeBar.php(69): wpforms_render('education/admin...', Array, true)
#3 /home/pagename/public_html/wp-includes/class-wp-hook.php(303): WPForms\Lite\Admin\Education\Admin\NoticeBar->display('')
#4 /home/pagename/public_html/wp-includes/class-wp-hook.php(327): WP_Hook->apply_filters('', Array)
#5 /home/vpagename/public_html/wp-includes/plugin.php(470): WP_Hook->do_action(Arra

Wordpress plugin fatal error

I downloaded this taxi booking plugin from Github but when I try to activate it on wordpress I get a fatal error and it doesn't let me activate it. You can find the plugin on https://github.com/mbejda/TaxiCabBookingSystem
Fatal error: Uncaught exception 'Braintree_Exception_Configuration' with message 'merchantIdneeds to be set' in /Applications/MAMP/htdocs/DocklandsTaxi/wp-content/plugins/TaxiCabBookingSystem-master/lib/Braintree/Configuration.php:117 Stack trace: #0 /Applications/MAMP/htdocs/DocklandsTaxi/wp-content/plugins/TaxiCabBookingSystem-master/lib/Braintree/Configuration.php(139): Braintree_Configuration::get('merchantId') #1 /Applications/MAMP/htdocs/DocklandsTaxi/wp-content/plugins/TaxiCabBookingSystem-master/lib/Braintree/Configuration.php(157): Braintree_Configuration::setOrGet('merchantId', NULL) #2 /Applications/MAMP/htdocs/DocklandsTaxi/wp-content/plugins/TaxiCabBookingSystem-master/modules/BookingSystemBrainTreeModule.php(32): Braintree_Configuration::merchantId(NULL) #3 /Applications/MAMP/htdocs/DocklandsTaxi/wp-content/plugins/TaxiCabBookingSystem-master/main.php(177): BookingSystemBrainTreeModule->__construct(Object(BookingSystem)) #4 /Applications/MAMP/htdocs/DocklandsTaxi/wp-content/plugins/TaxiCabBookingSystem-maste in /Applications/MAMP/htdocs/DocklandsTaxi/wp-content/plugins/TaxiCabBookingSystem-master/lib/Braintree/Configuration.php on line 117
Any help to get this resolved would be appreciated.
UPDATE at Sunday 8th Feb # 8:18pm.
I have added the Merchant ID on Configuration.php its giving me the same error I think, if not the same then very simular
Fatal error: Uncaught exception 'Braintree_Exception_Configuration' with message 'publicKeyneeds to be set' in /Applications/MAMP/htdocs/DocklandsTaxi/wp-content/plugins/TaxiCabBookingSystem-master/lib/Braintree/Configuration.php:117 Stack trace: #0 /Applications/MAMP/htdocs/DocklandsTaxi/wp-content/plugins/TaxiCabBookingSystem-master/lib/Braintree/Configuration.php(139): Braintree_Configuration::get('publicKey') #1 /Applications/MAMP/htdocs/DocklandsTaxi/wp-content/plugins/TaxiCabBookingSystem-master/lib/Braintree/Configuration.php(162): Braintree_Configuration::setOrGet('publicKey', NULL) #2 /Applications/MAMP/htdocs/DocklandsTaxi/wp-content/plugins/TaxiCabBookingSystem-master/modules/BookingSystemBrainTreeModule.php(33): Braintree_Configuration::publicKey(NULL) #3 /Applications/MAMP/htdocs/DocklandsTaxi/wp-content/plugins/TaxiCabBookingSystem-master/main.php(177): BookingSystemBrainTreeModule->__construct(Object(BookingSystem)) #4 /Applications/MAMP/htdocs/DocklandsTaxi/wp-content/plugins/TaxiCabBookingSystem-master/ma in /Applications/MAMP/htdocs/DocklandsTaxi/wp-content/plugins/TaxiCabBookingSystem-master/lib/Braintree/Configuration.php on line 117
Regards
Did you read the error message output... it says
Message 'merchantId needs to be set' in
/Applications/MAMP/htdocs/DocklandsTaxi/wp-content/plugins/TaxiCabBookingSystem-master/lib/Braintree/Configuration.php
[Update]
Also check out https://www.braintreepayments.com/docs/php

Create subdomain by cpanel api

I register on youhosting.com and use domain that registered on godaddy.com. I want to create new subdomain by programming. I have already see the tutorial on cPanel Documentation 1 and Doc 2
After I implement it, it show errors :
Fatal error: Uncaught exception 'Exception' with message 'curl_exec threw error "couldn't connect to host" for https://bodoamat.com:2087/xml-api/listips?' in /home/u937182156/public_html/xmlapi.php:748 Stack trace: #0 /home/u937182156/public_html/xmlapi.php(666): xmlapi->curl_query('https://bodoama...', '', 'Authorization: ...') #1 /home/u937182156/public_html/xmlapi.php(2055): xmlapi->xmlapi_query('listips') #2 /home/u937182156/public_html/listips_example.php(44): xmlapi->listips() #3 {main} thrown in /home/u937182156/public_html/xmlapi.php on line 748
include 'xmlapi.php';
$ip='127.0.0.1';
$root_pass='mypassword';
$xmlapi = new xmlapi($host);
$xmlapi->set_port(2082);
$xmlapi->password_auth($my_user, $my_pass);
$xmlapi->set_debug(1);
print $xmlapi->api1_query($account, "Subdomain", "addsubdomain", array('user123', 'bodoamat.com'));
Any one may help me?
Thanks before
$xmlapi->api1_query($cpanelusr, 'SubDomain', 'addsubdomain', array('user123','bodoamat.com',0,0, '/public_html/directory_name'))

How to solve "Uncaught exception 'google\net\ProtocolBufferEncodeError'"

I'm using Google App Engine in combination with PHP.
After a couple request I get the following error
Fatal error: Uncaught exception 'google\net\ProtocolBufferEncodeError' with message 'Internal bug: Encoded size doesn't match predicted' in /base/data/home/runtimes/php/sdk/google/appengine/runtime/proto/ProtocolMessage.php:68
Stack trace:
#0 /base/data/home/runtimes/php/sdk/google/appengine/runtime/proto/ProtocolMessage.php(50): google\net\ProtocolMessage->serializePartialToString()
#1 /base/data/home/runtimes/php/sdk/google/appengine/runtime/RealApiProxy.php(52): google\net\ProtocolMessage->serializeToString()
#2 /base/data/home/runtimes/php/sdk/google/appengine/runtime/ApiProxy.php(42): google\appengine\runtime\RealApiProxy->makeSyncCall('taskqueue', 'BulkAdd', Object(google\appengine\TaskQueueBulkAddRequest), Object(google\appengine\TaskQueueBulkAddResponse), NULL)
#3 /base/data/home/runtimes/php/sdk/google/appengine/api/taskqueue/PushQueue.php(195): google\appengine\runtime\ApiProxy::makeSyncCall('taskqueue', 'BulkAdd', Object(google\appengine\TaskQueueBulkAddRequest), Object(google\appengine\TaskQueueBulkAddResponse in /base/data/home/runtimes/php/sdk/google/appengine/runtime/proto/ProtocolMessage.php on line 68
Fatal error: Uncaught exception 'google\net\ProtocolBufferEncodeError' with message 'Internal bug: Encoded size doesn't match predicted' in /base/data/home/runtimes/php/sdk/google/appengine/runtime/proto/ProtocolMessage.php:68
Stack trace:
#0 /base/data/home/runtimes/php/sdk/google/appengine/runtime/proto/ProtocolMessage.php(50): google\net\ProtocolMessage->serializePartialToString()
#1 /base/data/home/runtimes/php/sdk/google/appengine/runtime/RealApiProxy.php(52): google\net\ProtocolMessage->serializeToString()
#2 /base/data/home/runtimes/php/sdk/google/appengine/runtime/ApiProxy.php(42): google\appengine\runtime\RealApiProxy->makeSyncCall('taskqueue', 'BulkAdd', Object(google\appengine\TaskQueueBulkAddRequest), Object(google\appengine\TaskQueueBulkAddResponse), NULL)
#3 /base/data/home/runtimes/php/sdk/google/appengine/api/taskqueue/PushQueue.php(195): google\appengine\runtime\ApiProxy::makeSyncCall('taskqueue', 'BulkAdd', Object(google\appengine\TaskQueueBulkAddRequest), Object(google\appengine\TaskQueueBulkAddResponse in /base/data/home/runtimes/php/sdk/google/appengine/runtime/proto/ProtocolMessage.php on line 68
To solve this I shutdown all the instances and the code just loads normally. And again after a couple of request I get the same fatal error.
What can cause this Fatal error ? And how do I solve it.
The error is raised in the following file
https://chromium.googlesource.com/external/googleappengine/python/+/4523f63814037ed833b8bb55273c09a43dd69fb0/php/sdk/google/appengine/runtime/proto/ProtocolMessage.php

Categories