Executed request long time response arround 20 minutes , but it’s return an error
Category: PHP
Category Added in a WPeMatico Campaign
PHP Fatal error: Uncaught Error: Call to a member function nbIncidents() on array [closed]
i would like to print the result of an SQL request in my view in PHP (from scratch), I use PDO and mySQL
But I have this error :
Nombre d'incidents :
Fatal error: Uncaught Error: Call to a member function nbIncidents() on array in C:Applicationswamp64wwwportailviewsincidentincidents.view.php:7 Stack trace: #0 C:Applicationswamp64wwwportailcontrollersIncidentController.controller.php(47): require() #1 C:Applicationswamp64wwwportailindex.php(169): IncidentController->afficherIncidents() #2 {main} thrown in C:Applicationswamp64wwwportailviewsincidentincidents.view.php on line 7
My code :
in my Controller :
public function IncidentsCount()
{
$incidents = $this->incidentManager->nbIncidents();
require "views/incident/incidents.view.php";
}
my Manager :
public function nbIncidents(){
$req ="SELECT COUNT(*) FROM `incidents` WHERE clos = :nonclos";
$stmt = $this->getBdd()->prepare($req);
$stmt->bindValue(":nonclos", 0, PDO::PARAM_STR);
$stmt->execute();
$nbIncidents = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
return $nbIncidents;
}
my View :
<p>Nombre d'incidents : <?php $incidents->nbIncidents(); ?></p>
I also tested to make a simpler function to see, like this :
public function nbIncidents(){
$nbIncidents = 777;
echo $nbIncidents;
}
And I have the same error.
If someone knows how resolve this error, thanks in advance.
Sincerely,
GM
How to make permission levels on Php Maker 2022
I want to make permission levels. Administrator give permission as Manager with Add permission level but not edit or delete and view only what he made. Then Manager can make separate levels to his crew but that must have only below permissions than manager.
But when I try to make a user as a manager level, it asks what permissions are giving. When I add all, That user get Administrator level permission. I used User ID Level to get what Manager Create.
On the Other hand as a manager level When I load select box with permission levels it shows Administrator. That mean Manager can make Administrator.
I want to Do
Administrator(give Privilege to make user) -> Manager(can make permissions for users) -> users(must have lower than manager level)
Please help me…
I used User Id Level, Advance Security Option, Dynamic Table Security. In Phpmaker 2022
Problem with WordPress PHP configuration and ,
I am configurating a HTML website to WordPress with PHP. But I keep getting these “Errors” on https://validator.w3.org/:
It regards these 2 codes that I put in header.php:
'items_wrap' => '<ul class="top-menu"><li><a href="<?php get_permalink()?></a></li>%3$s</ul>'
'items_wrap' => '<ul class="nav-menu"><li class="nav-item"><a href="<?php get_permalink()?> class="nav-link"</a></li>%3$s</ul>
I get these errors:
Error: No space between attributes.
Error: Saw < when expecting an attribute name. Probable cause: Missing > immediately before.
Error: A slash was not immediately followed by >.
Error: Bad value for attribute href on element a: Illegal character in path segment: < is not allowed.
Error: Attribute < not allowed on element a at this point.
Error: End tag li seen, but there were open elements.
Error: Unclosed element a
Error: Start tag a seen but an element of the same type was already open.
Error: No a element in scope but a a end tag seen.
I am not yet that strong in PHP, and I have tried to remove all a and li, but that only created other “errors” at validator.
So, i understand the these 2 code lines are not properly created. I got these codes from a Youtuber. So what should I do, so these two code lines will pass in validator?
Using HTMX in Laravel
I’m using Laravel 9 and I’m looking for a way to use HTMX inside the Laravel blades.
So I tried including it at my master blade:
<script src="https://unpkg.com/[email protected]/dist/htmx.min.js"></script>
Then I changed this on my blade:
<form method="GET" action="{{ route('auth.login.next.passwd') }}">
<button id="login" class="btn">Get the password</button>
</form>
To this:
<button id="login" hx-get="{{ route('auth.login.next.passwd') }}" class="btn">Get the password</button>
However it does not work.
There must be something here that I’m doing wrong but I don’t know what is.
So if you know how to call htmx inside Laravel in order for using at blades, please let me know, thanks.
how password_verify() function actually works in PHP
I am wondering about how password_verify() verifies the hash, I have reviewed the documentation and many answers in StackOverflow, but I didn’t get the idea
because, as I understood, this function will compare the hash with entered password after hashing it again, and use the same salt and cost and algorithm,
but the question here: if anyone can separate the salt from the hashed password, then anybody also can try to use rehash and try to match, and the salt will be useless here. Am I right, or what?
TypeError: Argument 1 passed to IlluminateCookieMiddlewareEncryptCookies::encrypt()
TypeError: Argument 1 passed to IlluminateCookieMiddlewareEncryptCookies::encrypt() must be an instance of SymfonyComponentHttpFoundationResponse, array given, called in /Users/hamzagill/Desktop/Forborga-Backend/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php on line 67 in file /Users/hamzagill/Desktop/Forborga-Backend/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php on line 138
Laravel – Can’t update multiple columns at once
I have $projectFieldOptions variable and it’s output is this https://codeshare.io/0gN9V8.
Now, I want to update the table based on the id_feed_mappings column. To do that I am running this code but it’s not updateing:
foreach ($projectFieldOptions as $mapping) {
if($mapping['custom']) {
$internal_field_slug = $mapping['custom_field'];
} else {
$internal_field_slug = isset( $mapping['text'] ) ? $mapping['text'] : '';
}
$field_mapping = DB::connection($db_name)->table($db_name . ".feed_mappings")->where('id_feed_mappings', $mapping['id_feed_mappings'])->update([
'id_feed' => $id_feed,
'id_project' => $token,
'import_field_slug' => $mapping['value'],
'internal_field_slug' => $internal_field_slug,
'custom_field' => $mapping['custom'],
'updates' => $mapping['updates'],
'removes' => $mapping['removes'],
'import' => 1,
'date_add' => now(),
'date_upd' => now()
]);
}
How to automate wocommerce product uploading using the following code. Zero coding experience
To automate product uploading, I reach out to this link. I want to use this code. But I dont know how! I want a detailed step-by-step guaid about this.
plz, help me.
I try selenium but unfortunately stuck for 3-4 days in copy paste a simple text. When I search about selenium ide there is coding tutorial everywhere. So I took a hard decision to learn coding little..
How to place a Market Stop Loss order using Binance Spot API?
According to data provided by Binance Spot API endpoint there are no assets that support Market Stop Loss orders. Does Binance provide only Limit Stop Loss orders for spot? Did I miss something?
I tried to place a usual Market Stop Loss, but Binance rejected it with “Stop loss orders are not supported for this symbol” error.
Markdown. Replacing Two Matches preg_replace
It turns out to make one replacement, but no more than two.
**two examples: **
The first doesn’t work: $result_do_not_work
The Second one work: $result_work
$text_does_not_work = ' *spoiler-name*spoil*/spoiler-name**s-content*(shadow*010*shadow*)*/s-content* *spoiler-name*spoil*/spoiler-name**s-content*(shadow*010*shadow*)*/s-content* *spoiler-name*spoil*/spoiler-name**s-content*(shadow*010*shadow*)*/s-content*
[>google!<](LINK:https://google.com)';
$text_work = ' *spoiler-name*spoil*/spoiler-name**s-content*(shadow*010*shadow*)*/s-content*
[>google!<](LINK:https://google.com)';
$patt = ['~*spoiler-name*(.*)*/spoiler-name**s-content*((.*))*/s-content*~','~[>(.*)<]((.*))~'];
$repl=['<details><summary>$1</summary>$2</details>','<a href="$2">$1</a>'];/*<a href="$2">$1</a>*/
$result_work = preg_replace($patt, $repl, $text_work);
$result_does_not_work = preg_replace($patt, $repl, $text_does_not_work);
I tried a many things.
For example, this code also does not work:
$text='[s]SPOILER[s](content-sp) [s]SPOILER[s](content-sp) [s]SPOILER[s](content-sp)'; $patt = ['/[s]([^*]+)[s](([^*]+))/im']; $repl=['<details><summary>$1</summary>$2</details>']; $page = preg_replace($patt, $repl, $text);
result: SPOILER[s](content-sp) [s]SPOILER[s](content-sp) [s]SPOILER content-sp
PHP cookie not saved on specific case although setcookie returns true
I’m having a really weird bug with cookies in PHP and I need external view on this case because I can’t figure out what’s going on.
So basically here’s my code :
// Code below does NOT work
$incidents_infos = [];
foreach ($incidents as $incident) {
$incidents_infos[$incident->number]['urgency'] = $incident->urgency;
$incidents_infos[$incident->number]['service_name'] = $this->get_service_name_from_assignment_group($incident->assignment_group);
$incidents_infos[$incident->number]['to_notify'] = $incident->to_notify;
}
setcookie('queried_incidents', json_encode($incidents_infos));
Now the issue that I have and that’s really weird is that the cookie “queried_incidents” is actually set ONLY when the incidents inside $incidents_infos have at most 2 attributes (works with any of the 3 listed).
But when the incidents have the 3 attributes above all together : urgency, service_name, to_notify => although setcookie function DOES return TRUE, the cookie is not actually set in the browser in the end.
// Code below DOES work
$incidents_infos = [];
foreach ($incidents as $incident) {
$incidents_infos[$incident->number]['urgency'] = $incident->urgency;
//$incidents_infos[$incident->number]['service_name'] = $this->get_service_name_from_assignment_group($incident->assignment_group);
$incidents_infos[$incident->number]['to_notify'] = $incident->to_notify;
}
setcookie('queried_incidents', json_encode($incidents_infos));
Apparently is does not have anything to do with the nature of the values of these attributes because I tried any values. After multiple tests, it appears that the cookie is set when the incidents only have 1 or 2 attributes, and does not work with 3 attributes (but setcookie returns true anyway).
I really have NO idea what’s going on, does anyone have an idea ?
Thanks
Swift_TransportException Process could not be started [The system cannot find the path specified. Yii2
How to PestPHP tests in a specific order?
Looking at the Pest documentation seems that there is no way to run test in a specific order, except renaming file with something like “01_Auth…”, “02_Organization…”. This doens’t seem a standard or correct way to run tests that depend on others.
At the moment I have the following test files:
Feature
├── AuthTest.php
├── OrganizationTest.php
└── UserTest.php
So Pest will run tests in the following order:
1. AuthTest.php
2. OrganizationTest.php
3. UserTest.php
But I need to run tests in that order, since some tests depends on others:
1. UserTest.php
2. AuthTest.php
3. OrganizationTest.php
This is the flow:
UserTest.php register users on the database and AuthTest.php tries to authenticate with those Users.
In order to create an Organization, it’s necessary that there is at least 1 user associated, so it must be run after UserTest.php
How can I achieve this result in a standard way?
Php version in my vs code cli is showing 7.4.24 while in my laragon terminal is showing 8.1.13
php version in vs code is 7.4.24
php version in laragon terminal is 8.1.13. I want my vs code php version to be the same with the php version in my laragon