Skip to content

Tag: php

Insert into PDO with IF clause

I need some help with inserting some data into a sql server table using the IF clause. I have the return of an API that I insert in the table of the sql server. However, as I will schedule my code every day to get the update from the API to see if there is anything new, but every time

join a single table twice in join query

I have 3 tables users and meeting table and user_role. In user table I have user_name and user_role fields and in meeting table I have the column meeting_id assigned_username and created_by_user_name fields and In user_roles table have id and role . I want to get the assigned_user_name’s user_role and c…

I can’t get JWT token in Laravel

I am creating an API in Laravel 8 (PHP 7.4) and I wanted to secure it. The choice fell on tymon / jwt-auth. I follow the documentation from the website: https://jwt-auth.readthedocs.io/en/develop/quick-start/ Everything works fine here. However, later when I create a route to login and want to get the token u…

Combine neighbouring elemets to new array of min 2

I have a quite specific problem. I want to combine every element of an array with neighboring elements to a new array of minimum length 2. Im not sure if Im explaining that correctly so here’s an example: Given the array: I want to create a new array that looks like this: [‘abcd’] is not ret…

PHP topological sort

LIST: controller name => priority:required controllers sorted and expected output: First sort by priority, then reorder based on required controllers to be loaded before. ensure not to be stuck in an infinite loop due to controllers requiring each other. I assume I’ll need something like this: Please…

The cookie is not created js

I’m planning a registration system. Right now I’m trying to send a randomly generated session string to the mysql db; besides sending it on db I want to create a cookie with the js that contains the session string. I tried with the following code but I don’t know why the cookie is not genera…