Fatal error: Uncaught ArgumentCountError - php

I get this error. I created a button to update the table. When I click the button, I get an error. How to fix it?
Fatal error: Uncaught ArgumentCountError: Too few arguments to function personel::update_form(), 0 passed in C:\xampp\htdocs\warehouse\panel\system\core\CodeIgniter.php on line 360 and exactly 1 expected in C:\xampp\htdocs\warehouse\panel\application\controllers\personel.php:57 Stack trace: #0 C:\xampp\htdocs\warehouse\panel\system\core\CodeIgniter.php(360): personel->update_form() #1 C:\xampp\htdocs\warehouse\panel\index.php(202): require_once('C:\xampp\htdocs...') #2 {main} thrown in C:\xampp\htdocs\warehouse\panel\application\controllers\personel.php on line 57
Fİle Name: personel.php Controller
MY CODES
public function update_form($id){
$where = array( "id" => $id);
$personel = $this->Personel_model->get($where);
$viewData["personel"] = $personel;
$this->load->view("personel_edit");
}
MY BUTTON CODES
Update

You must pass an ID with the button to function in the controller like this.
Update

Related

Cannot retrieve Stripe data on success page

I have followed the Stripe documentation, trying to get the e-mail address of a customer but it fails with the following error:
PHP Fatal error: Uncaught exception 'Stripe\Exception\InvalidArgumentException'
with message 'The resource ID cannot be null or whitespace.' in /home/phuketto/public_html/stripe-php/lib/Service/AbstractService.php:99
Stack trace:
#0 /home/phuketto/public_html/stripe-php/lib/Service/Checkout/SessionService.php(90): Stripe\Service\AbstractService->buildPath('/v1/checkout/se...', NULL)
#1 /home/phuketto/public_html/ipnstripe.php(9): Stripe\Service\Checkout\SessionService->retrieve(NULL)
#2 {main}
thrown in /home/phuketto/public_html/stripe-php/lib/Service/AbstractService.php on line 99
In my create session script I am using:
'success_url' => 'https://www.example.com/ipnstripe.php?session_id={CHECKOUT_SESSION_ID}',
In my success_url I am trying to get the customer e-mail to be used further down the script but something goes wrong and the rest of the script is not executed:
require_once('./stripe-php/init.php');
$stripe = new \Stripe\StripeClient('sk_live_xxxxx');
$session = $stripe->checkout->sessions->retrieve($_GET['session_id']);
$customer = $stripe->customers->retrieve($session->customer);
$payeremail = $customer->email;

WordPress - WP_Widget : Fatal error: Uncaught ArgumentCountError: Too few arguments to function WP_Widget::__construct()

Im new to custom wordpress widget creation and im trying to create one. I created my widget at wp-content> plugins> custom-widgets> my-custom-widget.php.
This is my code
if(!class_exists("MyCustomWidget")){
class MyCustomWidget extends WP_Widget{
public function __constructor(){
parent::WP_Widget(false,"My custom Widget");
}
public function form($instance){
?>
<p>
<label>Tilte:</label>
<input type="text"/>
</p>
<?php
}
}
function register_my_widget(){
register_widget("MyCustomWidget");
}
add_action("widgets_init", "register_my_widget");
}
When im trying to activate it i get the wordpress fail page and specially the following. What is wrong?
Fatal error: Uncaught ArgumentCountError: Too few arguments to function WP_Widget::__construct(), 0
passed in F:\Downloads\Worpress\Wordpress Local\apache2\htdocs\store\wordpress\wp-includes\class-wp-
widget-factory.php on line 61 and at least 2 expected in F:\Downloads\Worpress\Wordpress
Local\apache2\htdocs\store\wordpress\wp-includes\class-wp-widget.php:162 Stack trace: #0
F:\Downloads\Worpress\Wordpress Local\apache2\htdocs\store\wordpress\wp-includes\class-wp-widget-
factory.php(61): WP_Widget->__construct() #1 F:\Downloads\Worpress\Wordpress
Local\apache2\htdocs\store\wordpress\wp-includes\widgets.php(115): WP_Widget_Factory->register() #2
F:\Downloads\Worpress\Wordpress Local\apache2\htdocs\store\wordpress\wp-content\plugins\custom-widget\wp-
custom-widget.php(34): register_widget() #3 F:\Downloads\Worpress\Wordpress
Local\apache2\htdocs\store\wordpress\wp-includes\class-wp-hook.php(287): register_my_widget() #4
F:\Downloads\Worpress\Wordpress Local\apache2\htdocs\store\wordpress\wp-includes\class-wp-hook.php(311):
WP in F:\Downloads\Worpress\Wordpress Local\apache2\htdocs\store\wordpress\wp-includes\class-wp-
widget.php on line 162
See this answer from wordpress.stackexchange.com for a full correct widget example.
There is a couple of issues with the code in this question:
It's function __construct() and not function __constructor().
As detailed in rich's answer the parent call should be to parent::__construct(..). For example: parent::__construct('', 'Widget name');
In your constructor, you need to pass 2 arguments... so something like this:
public function __constructor(){
parent::__construct('my_custom_widget',v__('My Custom Widget', 'my_text_domain'));
}
WordPress documentation here:
https://developer.wordpress.org/reference/classes/wp_widget/__construct/

Why am I getting an invalid parameter error when updating a customer attribute in Shopware?

I am trying to update customer attribute in Shopware but am getting an error:
$builder = $this->container->get('models')->createQueryBuilder()
->update(\Shopware\Models\Customer\Customer::class, 'customer')
->set('customer.active',0)
->where('customer.email= :email')
->setParameter('email ' ,'xyz#test.com');
$builder->getQuery()->execute();
Fatal error: Uncaught Doctrine\ORM\Query\QueryException: Invalid
parameter: token email is not defined in the query. in
/var/www/html/shopware/vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php:134
Stack trace: #0
/var/www/html/shopware/vendor/doctrine/orm/lib/Doctrine/ORM/Query.php(362):
Doctrine\ORM\Query\QueryException::unknownParameter('email ') #1
/var/www/html/shopware/vendor/doctrine/orm/lib/Doctrine/ORM/Query.php(319):
Doctrine\ORM\Query->processParameterMappings(Array) #2
/var/www/html/shopware/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php(962):
Doctrine\ORM\Query->_doExecute() #3
/var/www/html/shopware/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php(917):
Doctrine\ORM\AbstractQuery->executeIgnoreQueryCache(NULL, NULL) #4
/var/www/html/shopware/custom/plugins/CustomPlugin/Controllers/Frontend/CustomPlugin.php(17):
Doctrine\ORM\AbstractQuery->execute() #5
/var/www/html/shopware/engine/Library/Enlight/Controller/Action.php(193):
Shopware_Controllers_Frontend_CustomPlugin->indexAction() # in
/var/www/html/shopware/vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php
on line 134
How can I fix this?
Try to use a where statement like this;
->where('customer.email = ?1')->setParameter(1 ,'xyz#test.com');

Add function with parameters in smarty variable

I'm a prestashop developper and i want to add my custom function using parameters in a smarty variable.
There's my PHP function
function maFonctionSMarty($params)
{
$array['1'] = $params['monParametre'];
$array['2'] = $params['monParametre1'];
return $array;
}
and in m'y template i try to do this
{$a|maFonctionSMarty:"toto":"tata"}
and i have an error.
Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template "/Users/guillaume/Sites/prestashop_156/modules/wb_newsletter/admin_panel.tpl" on line 94 "{$a|maFonctionSMarty:"toto":"tata"}" unknown modifier "maFonctionSMarty"' in /Users/guillaume/Sites/prestashop_156/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php:667 Stack trace: #0 /Users/guillaume/Sites/prestashop_156/tools/smarty/sysplugins/smarty_internal_compile_private_modifier.php(132): Smarty_Internal_TemplateCompilerBase->trigger_template_error('unknown modifie...', 94) #1 /Users/guillaume/Sites/prestashop_156/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php(475): Smarty_Internal_Compile_Private_Modifier->compile(Array, Object(Smarty_Internal_SmartyTemplateCompiler), Array, NULL, NULL) #2 /Users/guillaume/Sites/prestashop_156/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php(259): Smarty_Internal_TemplateCompilerBase->callTagCompil in /Users/guillaume/Sites/prestashop_156/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php on line 667
[PrestaShop] Fatal error in module smarty_internal_templatecompilerbase:
Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template "/Users/guillaume/Sites/prestashop_156/modules/wb_newsletter/admin_panel.tpl" on line 94 "{$a|maFonctionSMarty:"toto":"tata"}" unknown modifier "maFonctionSMarty"' in /Users/guillaume/Sites/prestashop_156/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php:667 Stack trace: #0 /Users/guillaume/Sites/prestashop_156/tools/smarty/sysplugins/smarty_internal_compile_private_modifier.php(132): Smarty_Internal_TemplateCompilerBase->trigger_template_error('unknown modifie...', 94) #1 /Users/guillaume/Sites/prestashop_156/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php(475): Smarty_Internal_Compile_Private_Modifier->compile(Array, Object(Smarty_Internal_SmartyTemplateCompiler), Array, NULL, NULL) #2 /Users/guillaume/Sites/prestashop_156/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php(259): Smarty_Internal_TemplateCompilerBase->callTagCompil
thanks
You have to put that function as a plugin in a separate file named modifier.maFonctionSMarty.php in tools/smarty/plugins. Also, the name of the function has to be different:
function smarty_modifier_maFonctionSMarty($params)

Doctrine QueryBuilder returns QueryException

I'm trying to get my Page Entities using the Doctrine QueryBuilder. I have succesfully implemented the ORM and it generated my database without any trouble. Now that I want to grab the Entities from the database, it seems to return a QueryException
Fatal error: Uncaught exception 'Doctrine\ORM\Query\QueryException' with message 'SELECT page FROM Website\Model\Body\Page page WHERE page.isActive = 1' in path\to\orm\Doctrine\ORM\Query\QueryException.php:39
Stack trace:
#0 path\to\orm\Doctrine\ORM\Query\Parser.php(429): Doctrine\ORM\Query\QueryException::dqlError('SELECT page FRO...')
#1 path\to\orm\Doctrine\ORM\Query\Parser.php(854): Doctrine\ORM\Query\Parser->semanticalError('Class 'Website\...', Array)
#2 path\to\orm\Doctrine\ORM\Query\Parser.php(1529): Doctrine\ORM\Query\Parser->AbstractSchemaName()
#3 path\to\orm\Doctrine\ORM\Query\Parser.php(1426): Doctrine\ORM\Query\Parser->RangeVariableDeclaration()
#4 path\to\orm\Doctrine\ORM\Query\Parser.php(1168): Doctrine\ORM\Query\Parser->IdentificationVariableDeclaration()
#5 path\to\orm\Doctrine\ORM\Query\Parser.php(757): Doctrine\ORM\Query\Parser->FromClause()
#6 path\to\ in path\to\orm\Doctrine\ORM\Query\QueryException.php on line 49
This piece of code causes the trouble
public function getActivePages()
{
$qb = \WebTools\Doctrine\Doctrine::instance()->getQueryBuilder();
$qb->select('page')
->from('Website\Model\Body\Page', 'page')
->where($qb->expr()->eq("page.isActive", true));
$query = $qb->getQuery();
$result = $query->getResult();
\Doctrine\Common\Util\Debug::dump($result);
die();
return $result;
}
Any help is appreciated, thanks
Try
$qb->select('page')
->from('Page', 'page')
or
$qb->select('page')
->from('\Website\Model\Body\Page', 'page')
and make sure your class is mapped by dotrine.

Categories