October 22, 2024
Chicago 12, Melborne City, USA
PHP

Receiving invalid credentials at Endpoint

I am working on a Webhook API in Postman. In Postman, I have entered the username, password, and account code in the Headers. I am then sending the below payload directly to the website’s endpoint: { "email": "myemail@yahoo.com", "overwrite": true, "fields": { "first_name": "John", "last_name": "Doe", "country": "Chile", "mrc_c3": "300.00", "mrc_date_c3": "10/16/24" } } Using

Read More
PHP

Why shouldn't I use mysql_* functions in PHP?

I have tried multiple ways to get this to work, but all it shows are 5 grey stars. Of the 25 search results I get, I was expecting 1 result to have 5 gold stars, 1 to have 3 gold stars/2 grey stars with the other results displaying all 5 grey stars. Here’s is my

Read More
PHP

regex to remove all whitespaces except between brackets

How do i prevent preg_replace() altering the content of () in following JavaScript-Snippet: myVar.replace(/\u00AD/g, ''); This is my PHP function (I am not sure, which part is responsible): $output = preg_replace('/true/', '!0', $output); $output = preg_replace('/(?:(?:\/\*(?:[^*]|(?:\*+[^*\/]))*\*+\/)|(?:(?<!\:|\\\)\/\/[^"\'].*))/', '', $output); $output = preg_replace('/ = /', '= ', $output); $output = preg_replace('/\s*\n\s*/', '', $output); $output = preg_replace('/([^A-Za-z0-9\_\$])\h/', '$1',

Read More
PHP

Google ads API PHP cannot run the documentation example

I’m running symfony 6 server / php 8.0.8, google ads api V22.0.0. Got dev token/refresh token, and all other infos, and annot run simple example from google and I’m not sure what I’m doing wrong. Here is my code: use Google\Ads\GoogleAds\Lib\V14\GoogleAdsClientBuilder; use Google\Ads\GoogleAds\Lib\OAuth2TokenBuilder; use Google\Ads\GoogleAds\V14\Services\GoogleAdsServiceClient; use Google\Ads\GoogleAds\V14\Services\SearchGoogleAdsStreamRequest; $developerToken = 'xxxx'; $clientId = 'yyyy'; $clientSecret="zzzz"; $refreshToken

Read More
PHP

Updating Material Variant IDs for Product Variants in Laravel: Distinct Mapping Issue

I’m working on a Laravel application where I need to update the material_variant_id for product variants based on a provided list of materials. I have two tables: test_product_variant: Contains product variants with a product_id. Columns: id, product_id, … test_product_material_variant: Contains material variants linked to the product variants. Columns: product_variant_id, material_id, material_variant_id Problem: I need to

Read More
PHP

Laravel: error when trying to start up server

I installed composer, php and laravel via below code as found in the Laravel docs Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://php.new/install/windows')) creation of a new app worked fine, when running "php artisan serve" the server starts, then throws below error and shuts itself down Undefined array key 1

Read More
PHP

SWOOLE usage with PHP as backend

I use PHP/Nginx as backend for my App. I was afraid that when many users are calling functions into PHP, it will slow down as PHP does not support Async function calls. I check the below MacOS terminal command to get max calls/second by following command : wrk -t4 -c100 http://103.22.110.32:80/a.php results: Running 10s test

Read More
PHP

Update two SQL tables from one form (PHP)

I have two tables i would like to update from the results of 1 form that is posted. Table: Rescue Patients Patient ID Name Status 1 Bodger Released 2 Badger Captive Table: Admissions Admission ID Patient ID Disposition 1 2 Died 2 1 Released The form contains a look-up field with 6 options in a

Read More
PHP

PHP cURL unable to set private key file: 'C:\…\cacert.pem' type PEM

I’m trying to run the PHP cURL request example of an API from a Windows/IIS web server Here is the code: <?php $curl = curl_init(); curl_setopt($curl, CURLOPT_SSLCERT, 'C:\...\cacert.pem'); curl_setopt($curl, CURLOPT_VERBOSE, true); $streamVerboseHandle = fopen('php://temp', 'w+'); curl_setopt($curl, CURLOPT_STDERR, $streamVerboseHandle); curl_setopt_array($curl, [ CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30,

Read More
PHP

Stored Procedures, MySQL and PHP

I’ve been doing what I’m about to explain using ASP classic and ASP.Net with MSSQL Server for all that time and it works beautifully! Here below is the simplest example, one of MANY, and connection methods I have tried that utterly fails, just like all the rest. The SP works in MariaDb when Executed, but

Read More