I am trying to run PHPWord’s basic example in here on my Mac. I am using XAMPP as app server. I only changed the require_once part and added sys_get_temp_dir() in front of the file name because of the “ZipArchive::close(): Failure to create temporary file: Permission denied” error as same as…
Tag: php
How to check duplicate but without refresh page? PHP
this is my coding. I want to check the duplicate data. If duplicate data exists, the alert will pop-out, but once I click on OK, it will go to a blank page and cannot return to the form. How to make it pop-out an alert but without refresh the page? Answer One of the solutions is to do a javascript
Laravel CRUD API Fatal Error: Trait ‘IlluminateDatabaseEloquentFactoriesHasFactory’ not found
I was following this tutorial, but with my own dataset: https://www.positronx.io/php-laravel-crud-operations-mysql-tutorial And I got stuck on the phase of Creating and storing data. After filling all the fields: Im getting this error: When I comment use HasFactory it’s showing this Please help! Answer …
MySQL SUM of multiple rows from multiple table
I am trying to get the sum of multiple rows from 2 different tables, but somehow the result returns multiple rows. I need to get the SUM of quotation_item_amount (group by quotation_id) and invoice_item_amount (group by invoice_id) and if I query unpaid quotation, I need to get WHERE SUM(invoice) < SUM(quo…
Design pattern to reduce cyclomatic complexity
I have to send invoices to cutomers through the related customer’s API. Each customer chooses how to be contacted (email, fax, sms…). My problem is that each time I add a new “contact type” I increase the cyclomatic complexity of my script. Here is my code : As you can see the switch s…
string to xHH in PHP
I am curious is that any build in or easier way to encode string to xHH format in PHP? I am trying to implement rule 3 and rule 4 from XSS OWASP Prevention with build in function or easier approach. but, I can’t find any in the internet. as far as I found, I need to make manual encoder/decoder for
I want to update the purchases table quantity value from order_item if the order is canceled in php
Please check the below code and please help me the correct syntax to used. $changeStatusSql = ” UPDATE purchases SET quantity = (select purchases.quantity+order_item.quantity as q …
Laravel app interacting with a 3rd party API to get a token
I have one Laravel app with a GUI where the user logs in based on the data from a MySQL database. When the user logs in, the server needs to make a request to a specific endpoint of a 3rd party API in …
PHP – Unicode Problem conversion in json output
The outputted string in json is: u062eu0637u0627u06cc u0627u062du0631u0627u0632 u0647u0648u06ccu062a I tried json_decode with and without JSON_UNESCAPED_UNICODE but no luck. Something …
Navigation as a separate page in PHP
I am using my Navigation as a separate page which is Navigation.php and I am adding this page by <?php include ‘header.php’; ?> in everypage. But when I am going on a page, for example: going to About page, that About button in navigation bar have a class class=’active’ and that …