Welcome Guest, Not a member yet? Register   Sign In
  CI 3.1.13 + PHP 7.4 DB error
Posted by: Smekke - 09-21-2023, 08:24 AM - Replies (1)

So I inherited an older site running CI 3.0.x
I have upgraded CI 3 to the latest version (3.1.13).
Currently running PHP 7.0.33
I'd want to upgrade to PHP 7.4.33 to be at least a little more up-to-date but whenever I do that I get a very random error on the index page.

Error Number: 1146
Table 'database.A' doesn't exist
SELECT a.* FROM A a WHERE a.`show` = 1 ORDER BY a.A LIMIT 5
Filename: models/Mod_modules.php
Line Number: 1363
It seems to try and perform a select from a random table called 'A'?
Obviously it doesn't exist but I can't really figure out why the change in PHP suddenly results in this bogus query running.

in database.php, my dbprefix = ''. I don't have any prefixes on the tables.

Hoping someone might have an idea.

  Intro to HTMX: Dynamic HTML without JavaScript
Posted by: InsiteFX - 09-21-2023, 04:38 AM - No Replies

Intro to HTMX: Dynamic HTML without JavaScript

HTMX is the HTML extension syntax that replaces JavaScript with simple markup. It could change the course of web development.

  Update 4.4.1 makes it slower
Posted by: LuxesR - 09-20-2023, 05:18 AM - Replies (7)

I've updated from CodeIgniter 4.3.6 to 4.4.1. But it seems much slower. Like 2 seconds more load time. I've checked it on the same environment. 
Is there a setting I missed? I've added setAutoRoute on true to Routes.php (and $autoRoutesImproved in Feature.php on true as well)

Also, this doesn't seem to work anymore:

$this->Invoices = new Invoices_model();

So, I changed to this:
$this->Invoices = new \App\Models\Invoices_model();

Which all works fine, but it's slower. The rest is pretty much the same as it was before. Hope someone can help me.

Lightbulb Smarter forms in regards to ENTER key
Posted by: joho - 09-20-2023, 01:07 AM - Replies (4)

It'd be lovely if a "smarter forms" handling in regards to the ENTER key could be added, with or without the form builder, and purely optional (of course).

By "smarter forms" I mean that ENTER in an input field quite frequently should not submit the form, but either stay in the current field, or move to the next (visible) field (or radio/checkbox) as it does with the TAB key.

(This obviously can't be done in a TEXTAREA field)

Sad pagination next and previous cannot active
Posted by: phuth - 09-19-2023, 08:31 AM - Replies (1)

Hi everyone

i am using ci4.2
i have problem with pagination
$pager->hasPrevious() == null -> it work, i just set first page, but previous cannot run,
i try to var_dump($pager->hasNext())-> result is false
i 3 pages when using pagination in controller and it run, but next and previous cannot run, show i use ==null with next and previous to get first and last page
i dont know how to solve
$result = $post->like('post_title', $key)->orLike('post_intro', $key)->paginate(10, 'post');
'pager'        => $post->pager,

Full Pagi


use CodeIgniter\Pager\PagerRenderer;

* @var PagerRenderer $pager

<div aria-label="<?= lang('Pager.pageNavigation') ?>">
<ul class="pagination pagination-transparent pagination-rounded">
<?php // var_dump($pager->hasNext()); ?>
<?php if ($pager->hasPrevious() == null) : ?>
<li class="page-item">
<a class="page-link border" href="<?= $pager->getFirst() ?>" aria-label="Previous" >
<span aria-hidden="true"><i class="fas fa-fast-backward"></i></span>
<!-- <li class="page-item disabled">
<a class="page-link" href="<?= $pager->getPrevious() ?>" aria-label="Previous">
<span aria-hidden="true"><i class="fas fa-chevron-left"></i> Previous</span>
</li> -->
<?php endif ?>

<?php foreach ($pager->links() as $link) : ?>
<li <?= $link['active'] ? 'class="page-item active"' : 'class="page-item fw-bold"' ?>>
<a class="page-link" href="<?= $link['uri'] ?>" >
<?= $link['title'] ?>
<?php endforeach ?>

<?php if ($pager->hasNext() == null) : ?>
<!-- <li class="page-item disabled">
<a href="<?= $pager->getNext() ?>" aria-label="Next" class="page-link border">
<span aria-hidden="true">Next <i class="fas fa-chevron-right"></i></span>
</li> -->
<li class="page-item">
<a href="<?= $pager->getLast() ?>" aria-label="Next" class="page-link border">
<span aria-hidden="true"><i class="fas fa-fast-forward"></i></span>
<?php endif ?>


<?= $pager->links("post") ?>

Thank bro

  composer settings and phpstorm
Posted by: badger - 09-19-2023, 04:48 AM - Replies (2)

Its very minor query and my project works fine but I'd like to sort it out once and for all so as to have everything correct. As an example, the file "siteapps/vendor/codeigniter4/shield/src/Authentication/Authentication.php" has a namespace of "CodeIgniter\Shield\Authentication". PhpStorm highlights it and says "Namespace name doesnt match the PSR-0/PSR-4 project structure" and suggests moving it to "vendor/Codeigniter/Shield/Authentication". The same warning applies to all the files under siteapps/vendor. Is there something I can change in the vendor/composer/... settings or the phpstorm settings to make this warning go away?
Thanks, Bill

  Writing Clean Code: Best Practices and Principles
Posted by: InsiteFX - 09-18-2023, 04:26 AM - Replies (2)

Writing Clean Code: Best Practices and Principles

Question JWT Authentication
Posted by: erfin - 09-18-2023, 12:37 AM - Replies (3)


I followed the tutorial on JWT Authentication 

I tried to enter the wrong token like


response :


    "error": "The token is invalid."


when I remove one character from the token, like


why I don't get any false token response?

response :

<br />
<b>Fatal error</b>:  Uncaught CodeIgniter\Format\Exceptions\FormatException: Failed to parse JSON string. Error: Malformed UTF-8 characters, possibly incorrectly encoded in C:\Users\telo\cijwt\vendor\codeigniter4\framework\system\Format\JSONFormatter.php:41
Stack trace:
#0 C:\Users\telo\cijwt\vendor\codeigniter4\framework\system\Format\JSONFormatter.php(41): CodeIgniter\Format\Exceptions\FormatException::forInvalidJSON('Malformed UTF-8...')
#1 C:\Users\telo\cijwt\vendor\codeigniter4\framework\system\API\ResponseTrait.php(345): CodeIgniter\Format\JSONFormatter-&gt;format(Array)
#2 C:\Users\telo\cijwt\vendor\codeigniter4\framework\system\API\ResponseTrait.php(98): CodeIgniter\Debug\ExceptionHandler-&gt;format(Array)
#3 C:\Users\telo\cijwt\vendor\codeigniter4\framework\system\Debug\ExceptionHandler.php(78): CodeIgniter\Debug\ExceptionHandler-&gt;respond(Array, 500)
#4 C:\Users\telo\cijwt\vendor\codeigniter4\framework\system\Debug\Exceptions.php(147): CodeIgniter\Debug\ExceptionHandler-&gt;handle(Object(DomainException), Object(CodeIgniter\HTTP\IncomingRequest), Object(CodeIgniter\HTTP\Response), 500, 1)
#5 [internal function]: CodeIgniter\Debug\Exceptions-&gt;exceptionHandler(Object(DomainException))
#6 {main}
  thrown in <b>C:\Users\telo\cijwt\vendor\codeigniter4\framework\system\Format\JSONFormatter.php</b> on line <b>41</b><br />
    "title": "ErrorException",
    "type": "ErrorException",
    "code": 500,
    "message": "Uncaught CodeIgniter\\Format\\Exceptions\\FormatException: Failed to parse JSON string. Error: Malformed UTF-8 characters, possibly incorrectly encoded in C:\\Users\\telo\\cijwt\\vendor\\codeigniter4\\framework\\system\\Format\\JSONFormatter.php:41\nStack trace:\n#0 C:\\Users\\telo\\cijwt\\vendor\\codeigniter4\\framework\\system\\Format\\JSONFormatter.php(41): CodeIgniter\\Format\\Exceptions\\FormatException::forInvalidJSON('Malformed UTF-8...')\n#1 C:\\Users\\telo\\cijwt\\vendor\\codeigniter4\\framework\\system\\API\\ResponseTrait.php(345): CodeIgniter\\Format\\JSONFormatter->format(Array)\n#2 C:\\Users\\telo\\cijwt\\vendor\\codeigniter4\\framework\\system\\API\\ResponseTrait.php(98): CodeIgniter\\Debug\\ExceptionHandler->format(Array)\n#3 C:\\Users\\telo\\cijwt\\vendor\\codeigniter4\\framework\\system\\Debug\\ExceptionHandler.php(78): CodeIgniter\\Debug\\ExceptionHandler->respond(Array, 500)\n#4 C:\\Users\\telo\\cijwt\\vendor\\codeigniter4\\framework\\system\\Debug\\Exceptions.php(147): CodeIgniter\\Debug\\ExceptionHandler->handle(Object(DomainException), Object(CodeIgniter\\HTTP\\IncomingRequest), Object(CodeIgniter\\HTTP\\Response), 500, 1)\n#5 [internal function]: CodeIgniter\\Debug\\Exceptions->exceptionHandler(Object(DomainException))\n#6 {main}\n  thrown\n【Previous Exception】\nCodeIgniter\\Shield\\Exceptions\\LogicException\nCannot decode JWT: Syntax error, malformed JSON\n#0 C:\\Users\\telo\\cijwt\\vendor\\codeigniter4\\shield\\src\\Authentication\\JWT\\JWSDecoder.php(31): CodeIgniter\\Shield\\Authentication\\JWT\\Adapters\\FirebaseAdapter->decode('yJ0eXAiOiJKV1Qi...', 'default')\n#1 C:\\Users\\telo\\cijwt\\vendor\\codeigniter4\\shield\\src\\Authentication\\JWTManager.php(83): CodeIgniter\\Shield\\Authentication\\JWT\\JWSDecoder->decode('yJ0eXAiOiJKV1Qi...', 'default')\n#2 C:\\Users\\telo\\cijwt\\vendor\\codeigniter4\\shield\\src\\Authentication\\Authenticators\\JWT.php(153): CodeIgniter\\Shield\\Authentication\\JWTManager->parse('yJ0eXAiOiJKV1Qi...', 'default')\n#3 C:\\Users\\telo\\cijwt\\vendor\\codeigniter4\\shield\\src\\Authentication\\Authenticators\\JWT.php(73): CodeIgniter\\Shield\\Authentication\\Authenticators\\JWT->check(Array)\n#4 C:\\Users\\telo\\cijwt\\vendor\\codeigniter4\\shield\\src\\Filters\\JWTAuth.php(43): CodeIgniter\\Shield\\Authentication\\Authenticators\\JWT->attempt(Array)\n#5 C:\\Users\\telo\\cijwt\\vendor\\codeigniter4\\framework\\system\\Filters\\Filters.php(182): CodeIgniter\\Shield\\Filters\\JWTAuth->before(Object(CodeIgniter\\HTTP\\IncomingRequest), NULL)\n#6 C:\\Users\\telo\\cijwt\\vendor\\codeigniter4\\framework\\system\\CodeIgniter.php(466): CodeIgniter\\Filters\\Filters->run('', 'before')\n#7 C:\\Users\\telo\\cijwt\\vendor\\codeigniter4\\framework\\system\\CodeIgniter.php(353): CodeIgniter\\CodeIgniter->handleRequest(NULL, Object(Config\\Cache), false)\n#8 C:\\Users\\telo\\cijwt\\public\\index.php(79): CodeIgniter\\CodeIgniter->run()\n#9 C:\\Users\\telo\\cijwt\\vendor\\codeigniter4\\framework\\system\\Commands\\Server\\rewrite.php(47): require_once('C:\\\\Users\\\\telo\\\\c...')\n#10 {main}",
    "file": "C:\\Users\\telo\\cijwt\\vendor\\codeigniter4\\framework\\system\\Format\\JSONFormatter.php",
    "line": 41,
    "trace": [
            "function": "shutdownHandler",
            "class": "CodeIgniter\\Debug\\Exceptions",
            "type": "->",
            "args": []


  Improving responsive data table UX with CSS
Posted by: InsiteFX - 09-16-2023, 06:57 AM - No Replies

Improving responsive data table UX with CSS

  Events and Controllers...
Posted by: trunky - 09-15-2023, 12:51 PM - Replies (3)

Hi everyone,
I like to achieve simply logging the views of my pages in the database. Still learning CI4 though...
I found the Events and was looking at it the whole night. I have a Controller "Statistics" as well as a model. I've read I have to add the full namespace like App\Controllers\Statistics.

PHP Code:
Events::on('post_system', ['\App\Controllers\Statistics''write']); 
won't work still as it let's me know it isn't called static.

So... any help and/or additional insights how the Events work? I didn't figure it yet, obviously Smile

Welcome, Guest
You have to register before you can post on our site.



Latest Threads
Why unable to connect to ...
by petrogromovo
9 hours ago
How do I Migrate from 4.3...
by kenjis
Yesterday, 05:41 PM
PHP 8.2.11. This is a bug...
by wdeda
Yesterday, 02:33 PM
Parser - Conditions in Lo...
by ltarrant
09-29-2023, 11:00 PM
Session Flashdata Persist...
by ltarrant
09-29-2023, 10:56 PM
Shield's autoloading perf...
by kenjis
09-29-2023, 04:00 AM
Let's share custom valida...
by dgvirtual
09-29-2023, 03:17 AM
Unable to install Bonfire...
by dgvirtual
09-29-2023, 03:15 AM
CI4 PDF Customized
by kenjis
09-28-2023, 10:52 PM
Headers not properly set ...
by bgeneto
09-28-2023, 11:32 AM

Forum Statistics
» Members: 66,618
» Latest member: bidome
» Forum threads: 77,047
» Forum posts: 373,446

Full Statistics

Search Forums

(Advanced Search)

Theme © iAndrew 2016 - Forum software by © MyBB