We have a Magento 2 website. For some reason our Nginx/PHP-FPM is unable to read files from MAGEROOT/pub/ folder other than index.php. We are getting the following error in Nginx Log “Unable to open primary script: /home/goodprice/public_html/releases/current/pub/get.php (No such file or directory)̶…
Tag: php
PHP showing XML calendar data – merge day events
I have the following XML file, which I can’t edit. I am then outputting this using simplexml_load_file($url) into a PHP file: This gives me an output as follows: However, I would like to merge events by date, so the output would be as follows: How can I achieve this without editing the XML file? Thanks!…
Race condition with multiple updates PHP & MySQL
I have a table called cards, Each user can create/have multiple cards. One of the cards must be set as default. Sometimes when a user performs multiple requests to set another card as default at the same time, In the end, There are two or more default cards. Initial table: id user_id is_default 1 50 0 2 50 1 …
Show a date depending on day and time
I have this script that echo’s the upcoming Thursday, unless it’s Wednesday because then it shows the Thursday a week later. This works great. But what I would like is to add a cut-off time on Wednesday on 5PM (17:00 GMT+1 / CEST). So before 5PM it will still show the next Thursday (day after) but…
Missing months in Calendar
I am trying to set values of any missing months in my nested array for specific years. Data: As you can see in the above array, year 2019 and 2018 have missing months. How can I can add those missing months and set the values to zero? Please advice. Answer Use array_replace() to overlay one array with another…
Perfexcrm api return 419 status code, how solve it?
I use perfexcrm api in my web application. As its document I pass the URL in postman and also pass authentication token in headers of postman and company name in params in postman. I try to fetch all customers so I use api/customers as a URL and as a method I use POST for this. But as a output postman
PHP preg_split() if it is NOT a number, + sign, bracket, new line or tab
I have the following operation which splits a string whenever it encounters an alphabet: I want to extend it in such a way that it splits the string whenever the variable encountered is NOT a number, bracket, plus sign, hyphen, newline or tab. I have written a regex which can match the above: But I need to ne…
PHP – Date Format to include a string
I am trying to format a PHP date to be of the following format: Wednesday 3rd November 2021 at 11:01am My code is below: $date = new DateTime($dateOfChange); $date = $date->format(‘l jS F Y “at” g:ia’); I have tried: $date = $date->format(‘l jS F Y “at” g:iaR…
Session put does not seem to be working properly
I’m working with Laravel 5.8 and I wanted to make sure that users can submit a form only every 2 hours (as long as a session is alive). So I tried this at the Controller: So by this, everytime a user submits a new request, session request_has_been_sent must be set. Therefore at the next time user submit…
How to decode a string in base64 with php
Hello i’m trying to decrypt a base64 string with php and i can’t figure it out. I am able to decrypt it with JavaScript using CryptoJS with the code below What is the equivalent of this code in PHP? Answer To decode and decode from base64 a string can use base64_encode() : and now to decode: Now c…