Warning: Undefined array key “options” in localhost

I am self learner, and am building website in WordPress. I have no knowledge of php. I am using xampp for local server and Elementor to WordPress and while I am updating site logo, It shows an error – ‘Warning: Undefined array key “options” in C:xampphtdocsbasicdesignswp-contentpluginselementor-promodulestheme-builderwidgetssite-logo.php on line 194’ in my browser. Please help me to resolve this. Thanks

Unable to connect to Interbase 2020 Database with PHP 8.2

We recently installed Interbase Server 2020 on Windows Server 2019
with Apache Server 2.4.57 (Win64) OpenSSL/3.1.2 PHP/8.2.10

I am able to connect to the Interbase SQL Database remotely with IBConsole Administrator Database Utility on port 3050.

The following link show the php info
including the interbase extension:

http://70.182.48.236/testphp.php

I am not able to connect to the Interbase SQL Database remotely with PHP 8.2.

$db = ibase_connect( DB_HOST.DB_NAME, DB_USER, DB_PASSWORD, 'ISO8859_1', 100, 1) OR die('Unable to connect to the loan servicing database. ');

I receive the following error:

Warning: ibase_connect(): connection rejected by remote interface in
C:Program FilesApache2htdocstest-sqlconnect.php on line 24

What can I do to connect to the Interbase 2020 Database remotely with PHP 8.2?

MacOS apache doesn’t load php 8.3.1 mongodb extension

I need help with including mongodb extension for php in apache on MacOs.
I installed php8.3.1, apache Apache/2.4.56 (Unix) and included mongodb extension in php (extension=”/usr/local/lib/php/pecl/20230831/mongodb.so”). Also included phpmodule in apache “LoadModule php_module /usr/local/Cellar/php/8.3.1/lib/httpd/modules/libphp.so”.

And when I check php modules in terminal I see mongodb there:

olegk@olg buddy-web % php -v
PHP 8.3.1 (cli) (built: Dec 20 2023 12:44:38) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.1, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.1, Copyright (c), by Zend Technologies

olegk@olg buddy-web % php --ini
Configuration File (php.ini) Path: /usr/local/etc/php/8.3
Loaded Configuration File:         /usr/local/etc/php/8.3/php.ini
Scan for additional .ini files in: /usr/local/etc/php/8.3/conf.d
Additional .ini files parsed:      /usr/local/etc/php/8.3/conf.d/ext-opcache.ini

olegk@olg buddy-web % php -m
[PHP Modules]
....
mongodb
....

But when I checked phpinfo() I don’t see mongodb module there
screenshot of phpinfo

I tried already all possible things and it still not load mogodb in apache. Maybe you know where issue can be?

Collect the url sent from the server by get

I have created a form to send data to the host website via get and must include a callback link so they can return the data as get when they finish processing the data, but the problem is that I don’t want to provide a callback link and i want to get back the entire get url line they send back. so is there any way?

i want to collect the entire get url they send back without the callback url

How do I remove the comma if there is no value?

I have a select field that gets its values from a database table. Not all records in the database have all fields. Some are null. I want my select field to show the name,iata,icao – a combination of these three seperated by a comma. The issue is that some of my fields do not have an icao and some do not have an iaata. Is there a way for me to alter my code such that if there is no icao or iata the comma is ignored.

Please see below:

enter image description here

enter image description here

The code i need to alter is below:

 <select name="airport1" class="airport1" id="airport1">
                    <option selected value="Add">Select Airport</option>

                    <?php
                    $mysqli = NEW MYSQLI("localhost", "root", "", "airports");
                    $resultSet = $mysqli->query("SELECT name,iata,icao 
    FROM airports order by name ASC;
    ");

?>

                    <?php
                    while ($rows = $resultSet->fetch_assoc()){
                        $name = $rows['name'];
                        $iata = $rows['iata'];
                        $icao = $rows['icao'];
                        echo "<option value='$name,$iata,$icao'>$name,$iata,$icao</option>";
                    }
?>

Shortcode with woocommerce_before_customer_login_form won’t reference overridden template file

I am currently using wordpress and am creating a customized theme, i succesfully over-ridden the old myaccount form-login.php file as it works perfectly for the my-account page, but I used a shortcode from here and used it on my theme

add_shortcode( 'wc_reg_form_bbloomer', 'bbloomer_separate_registration_form' );
 
function bbloomer_separate_registration_form() {
   if ( is_user_logged_in() ) return '<p>You are already registered</p>';
   ob_start();
   do_action( 'woocommerce_before_customer_login_form' );
   $html = wc_get_template_html( '/myaccount/form-login.php' );
   $dom = new DOMDocument();
   $dom->encoding = 'utf-8';
   $dom->loadHTML( utf8_decode( $html ) );
   $xpath = new DOMXPath( $dom );
   $form = $xpath->query( '//form[contains(@class,"register")]' );
   $form = $form->item( 0 );
   echo $dom->saveXML( $form );
   return ob_get_clean();
}

add_shortcode( 'wc_login_form_bbloomer', 'bbloomer_separate_login_form' );

function bbloomer_separate_login_form() {
   if ( is_user_logged_in() ) return '<p>You are already logged in</p>'; 
   ob_start();
   do_action( 'woocommerce_before_customer_login_form' );
   woocommerce_login_form( array( 'redirect' => wc_get_page_permalink( 'myaccount' ) ) );
   return ob_get_clean();
}

So after putting calling the shortcode in 2 separate pages, it still references the original template file for some reason, I put the above code in the functions.php file at the end after confirming compatibility with woocommerce. I am also pretty sure that the template override of the form-login.php works fine since I tried making some changes in the my-account page and it worked just fine. Hopefully I could get some help, thanks !

Complex PHP-DI Configuration based on build time variable

For my PHP-DI definitions I need to make complex calculations beforhand, which are based on other configurations not coming from PHP-DI (those configurations are stored at build time in a variable). As it is harder to explain, than to show, let me give a simplified example which will show, what I would like to do, but will actually not work.

First let’s build the container. The code here is nothing special and shoud work:

<?php

use DIContainer;
use DIContainerBuilder;

class MyContainerBuilder
{
    // @param number is the build time (configuration) variable
    // I would like to use later
    public function build(int $number): Container
    {
        $builder = new DIContainerBuilder();
        $builder->addDefinitions(['number' => $number]);
        // In config.php I now want to do some complex calculations
        $builder->addDefinitions(__DIR__ . '/config.php');
        // here the container may be compiled, such that in production, the complex 
        // calculations from `config.php` will only be done once (to my understanding)
        return $builder->build();
    }
}

Now comes the problematic part. The calculation in config.php

<?php

$number = $container->get('number');
// complex calculation:
$number += 1;

return [
    'improvedNumber' => $number,
];

This is of course not possible, since the php-di container seems not to be available in the configuration file. Is it still possible to make the value of $number somehow available in the config.php?

Sidenote: What I really try to archive is to determine a bunch of services, which shall be injected using php-di. Those services are located in several directories and those directories I must know, when searching for them in the config.php-file.

phpIPAM isntallation on Ubuntu 22.04.03 Live Server

I am trying to install phpIPAM on my Ubuntu live server.

I have installed and configured it with php8.1, Nginx, MariaDB but when I try to open the ip_address/phpipam/ in browser it returs the 404 Not Found.

My configuration files are:

/etc/nginx/conf.d/phpipam.conf

server {
    listen 80;
    server_name 10.10.11.76;

    root /var/www/html/phpipam;
    index index.php;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ .php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /.ht {
        deny all;
    }
}

/etc/nginx/sites-available/phpipam

server {
    listen 80;
    listen [::]:80;

    root /var/www/html/phpipam;
    index index.php index.html index.htm;

    server_name 10.10.11.76;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

#    location ~ .php$ {
#        include snippets/fastcgi-php.conf;
#        fastcgi_pass   unix:/var/run/php/php-fpm8.1.sock;

    location ~ .php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php8.1-fpm.sock; # Adjust version if necessary
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /.ht {
        deny all;
    }

    # Additional configuration for phpIPAM, if needed
}


/var/www/html/phpipam/config.php

...
/**
 * database connection details
 ******************************/
$db['host'] = 'localhost';
$db['user'] = 'phpipam';
$db['pass'] = 'my_password';
$db['name'] = 'phpipam';
$db['port'] = 3306;

...

if(!defined('BASE'))
        define('BASE', "/phpipam/");
...

/var/log/nginx/error.log

2023/12/22 13:52:33 [error] 4158#4158: *1 FastCGI sent in stderr: "PHP message: PHP Warning:  Constant BASE already defined in /var/www/html/phpipam/config.php on line 12PHP message: PHP Warning:  Undefined array key 0 in /var/www/html/phpipam/functions/classes/class.Rewrite.php on line 94PHP message: PHP Warning:  Constant BASE already defined in /var/www/html/phpipam/config.php on line 12PHP message: PHP Warning:  Constant BASE already defined in /var/www/html/phpipam/config.php on line 12PHP message: PHP Warning:  Constant BASE already defined in /var/www/html/phpipam/config.php on line 12PHP message: PHP Warning:  Constant BASE already defined in /var/www/html/phpipam/config.php on line 12PHP message: PHP Warning:  Constant BASE already defined in /var/www/html/phpipam/config.php on line 12PHP message: PHP Warning:  Constant BASE already defined in /var/www/html/phpipam/config.php on line 12PHP message: PHP Warning:  Constant BASE already defined in /var/www/html/phpipam/config.php on line 12PHP message: PHP Warning:  Constant BASE already defined in /var/www/html/phpipam/config.php on line 12PHP message: PHP Warning:  Constant BASE already defined in /var/www/html/phpipam/config.php on line 12PHP message: PHP Warning:  Constant BASE already defined in /var/www/html/phpipam/config.php on line 12PHP message: PHP Warning:  Constant BASE already defined in /var/www/html/phpipam/config.php on line 12PHP message: PHP Warning:  Constant BASE already defined in /var/www/html/phpipam/config.php on line 12PHP message: PHP Warning:  Undefined array key "HTTPS" in /var/www/html/phpipam/functions/classes/class.Common.php on line 828PHP message: PHP Warning:  Undefined array key "HTTPS" in /var/www/html/phpipam/functions/classes/class.Common.php on line 828PHP message: PHP Warning:  Undefined array key "SCRIPT_URL" in /var/www/html/phpipam/functions/classes/class.User.php on line 466PHP message: PHP Warning:  Undefined array key "SCRIPT_URL" in /var/www/html/phpipam/functions/classes/class.User.php on line 466PHP message
2023/12/22 13:57:30 [warn] 4402#4402: conflicting server name "10.10.11.76" on 0.0.0.0:80, ignored
2023/12/22 13:57:30 [warn] 4403#4403: conflicting server name "10.10.11.76" on 0.0.0.0:80, ignored
2023/12/23 04:56:40 [warn] 7416#7416: conflicting server name "10.10.11.76" on 0.0.0.0:80, ignored
2023/12/23 04:56:40 [warn] 7417#7417: conflicting server name "10.10.11.76" on 0.0.0.0:80, ignored
2023/12/23 05:00:22 [warn] 7485#7485: conflicting server name "10.10.11.76" on 0.0.0.0:80, ignored
2023/12/23 05:00:27 [warn] 7494#7494: conflicting server name "10.10.11.76" on 0.0.0.0:80, ignored
2023/12/23 05:00:27 [warn] 7496#7496: conflicting server name "10.10.11.76" on 0.0.0.0:80, ignored
2023/12/23 05:10:03 [warn] 7705#7705: conflicting server name "10.10.11.76" on 0.0.0.0:80, ignored
2023/12/23 05:10:03 [warn] 7706#7706: conflicting server name "10.10.11.76" on 0.0.0.0:80, ignored
2023/12/23 05:13:42 [warn] 7897#7897: conflicting server name "10.10.11.76" on 0.0.0.0:80, ignored
2023/12/23 05:13:42 [warn] 7898#7898: conflicting server name "10.10.11.76" on 0.0.0.0:80, ignored
2023/12/23 06:19:29 [warn] 10599#10599: conflicting server name "10.10.11.76" on 0.0.0.0:80, ignored
2023/12/23 06:19:29 [warn] 10600#10600: conflicting server name "10.10.11.76" on 0.0.0.0:80, ignored
2023/12/23 06:29:12 [warn] 11078#11078: conflicting server name "10.10.11.76" on 0.0.0.0:80, ignored
2023/12/23 06:29:12 [warn] 11079#11079: conflicting server name "10.10.11.76" on 0.0.0.0:80, ignored
2023/12/23 06:29:52 [warn] 11122#11122: conflicting server name "10.10.11.76" on 0.0.0.0:80, ignored
2023/12/23 06:29:52 [warn] 11123#11123: conflicting server name "10.10.11.76" on 0.0.0.0:80, ignored
2023/12/23 06:36:15 [warn] 11180#11180: conflicting server name "10.10.11.76" on 0.0.0.0:80, ignored
2023/12/23 06:36:15 [warn] 11181#11181: conflicting server name "10.10.11.76" on 0.0.0.0:80, ignored

Can you help with its configuration please? I was expecting to enter to the Installation menu of phpIPAM.

Can’t connect to mysql server from a specific remote system

I have mysql working on a server (lets say ServerA) and am trying to access it from another server (lets say ServerB).

The mysql connection works perfectly with localhost calls from same server.

It also works perfectly if I call it from my local windows system, and yet another online linux server (lets say ServerC).

But it does not connect from ServerB.

Error that I get is:
Can't connect to MySQL server on 'xx.xx.xx.xx' (115)

xx.xx.xx.xx being the ip of ServerB.

I have given remote access to this ip on the ServerA already (I had to give same access to my local system ip and also the ServerC ip in order to make them work).

I also did a test that even if I remove the remote access for the ServerB still the error message keeps saying:
Can't connect to MySQL server on 'xx.xx.xx.xx' (115)

While on the other hand, if I remove access for my local system ip (my internet ip) or for my ServerC ip, it immediately gives me the error:
Host 'xx.xx.xx.xx' is not allowed to connect to this MySQL server

My guess is that, the ServerB has some setting which is blocking the request to go out, is that possible?

The ServerB is a simple hosting server with below details:

cPanel Version: 110.0 (build 17)
Apache Version: 2.4.58
MySQL Version: 10.2.44-MariaDB-cll-lve
Architecture: x86_64
Operating System: linux
Kernel Version: 5.4.0-1105-gke

While the host server that has the mysql db (ServerA) is also a simple hosting server with below details:

cPanel Version: 110.0 (build 15)
Apache Version: 2.4.58
MySQL Version: 5.7.44-cll-lve
Architecture: x86_64
Operating System: linux
Kernel Version: 2.6.32-954.3.5.lve1.4.93.el6.x86_64

Does someone have any idea why mysql connection is blocked from ServerB only?

php:7.0.13-fpm failed to install gd

I am trying to install gd on my php:7.0.13-fpm image

RUN docker-php-ext-configure gd --with-gd --with-webp-dir --with-jpeg-dir 
    --with-png-dir --with-zlib-dir --with-xpm-dir --with-freetype-dir 
    --enable-gd-native-ttf

RUN docker-php-ext-install gd

and it fails on:

#17 11.10 Installing header files:           /usr/local/include/php/
#17 11.40 php: error while loading shared libraries: libssl.so.1.0.0: cannot open shared object file: No such file or directory
#17 11.40 error: /usr/src/php/ext/gd/gd.so does not exist
#17 11.40
#17 11.40 usage: /usr/local/bin/docker-php-ext-enable [options] module-name [module-name ...]
#17 11.40    ie: /usr/local/bin/docker-php-ext-enable gd mysqli
#17 11.40        /usr/local/bin/docker-php-ext-enable pdo pdo_mysql
#17 11.40        /usr/local/bin/docker-php-ext-enable --ini-name 0-apc.ini apcu apc

Any ideas on how it should be configured?

PHPMailer not sending emails – SMTP Configuration Issue

Question

I am facing an issue with PHPMailer where it doesn’t seem to be sending emails. I’ve set up a simple registration system, and the verification email using PHPMailer is not reaching the intended recipients. I’ve included the relevant code below:

<?php
// Include PHPMailer autoloader
require 'PHPMailer/PHPMailer.php';
require 'PHPMailer/SMTP.php';
require 'PHPMailer/Exception.php';

use PHPMailerPHPMailerPHPMailer;

// Include configuration
include 'config.php';

// Function to sanitize input
function sanitizeInput($input) {
    return htmlspecialchars(trim($input), ENT_QUOTES, 'UTF-8');
}

// Function to send verification email
function sendmail($to, $subject, $verificationCode) {
    $mail = new PHPMailer(true); // Set true for exceptions

    try {
        // Configure SMTP settings
        $mail->isSMTP();
        $mail->Host = 'smtp.gmail.com';
        $mail->SMTPAuth = true;
        $mail->Username = '[email protected]'; // Use the full Gmail address here
        $mail->Password = 'soafohendcfhclzn';
        $mail->Port = 587;  // Adjust the port if necessary
        $mail->SMTPSecure = 'tls'; // Add this line

        // Set email parameters
        $mail->setFrom('[email protected]', 'APIForm');
        $mail->addAddress($to);
        $mail->Subject = $subject;

        // Styled HTML body
        $mail->isHTML(true);
        $mail->Body = '
            <html>
            <head>
                <style>
                    body {
                        font-family: Arial, sans-serif;
                        background-color: #f4f4f4;
                        margin: 0;
                        padding: 20px;
                    }
                    .container {
                        max-width: 600px;
                        margin: 0 auto;
                        background-color: #fff;
                        padding: 20px;
                        border-radius: 5px;
                        box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
                    }
                    h1 {
                        color: #333;
                    }
                    p {
                        color: #555;
                    }
                    .verification-code {
                        font-size: 24px;
                        font-weight: bold;
                        color: #3498db;
                    }
                </style>
            </head>
            <body>
                <div class="container">
                    <h1>Account Verification Code</h1>
                    <p>Dear user,</p>
                    <p>Your verification code is: <span class="verification-code">' . $verificationCode . '</span></p>
                    <p>Thank you for registering!</p>
                </div>
            </body>
            </html>
        ';

        // Send the email
        $mail->send();

        // Email sent successfully
        return true;
    } catch (Exception $e) {
        // Email not sent
        return false;
    }
}

// Function to handle registration API
function register() {
    global $pdo;  // Make $pdo variable available in this function
    $subject = "APIForm Account Verification";

    // Assuming you receive registration data in the POST request
    $firstname = isset($_POST['firstname']) ? sanitizeInput($_POST['firstname']) : null;
    $lastname = isset($_POST['lastname']) ? sanitizeInput($_POST['lastname']) : null;
    $email = isset($_POST['email']) ? sanitizeInput($_POST['email']) : null;
    $password = isset($_POST['password']) ? sanitizeInput($_POST['password']) : null;
    $confirmPassword = isset($_POST['confirm_password']) ? sanitizeInput($_POST['confirm_password']) : null;

    // Check if all required fields are provided
    if ($firstname && $lastname && $email && $password && $confirmPassword) {
        // Check if passwords match
        if ($password === $confirmPassword) {
            // Check if the email already exists in the database
            $stmtCheckEmail = $pdo->prepare('SELECT COUNT(*) FROM accounts WHERE email = ?');
            $stmtCheckEmail->execute([$email]);
            $emailExists = (bool)$stmtCheckEmail->fetchColumn();

            if (!$emailExists) {
                // Generate a unique user token using uniqid
                $userToken = uniqid('user_', true);

                // Generate a 6-digit code
                $verificationCode = sprintf('%06d', mt_rand(0, 999999));

                // Sending verification email
                if (sendmail($email, $subject, $verificationCode)) {
                    // Hash the password for security
                    $hashedPassword = password_hash($password, PASSWORD_BCRYPT);

                    try {
                        // Insert data into the accounts table using a prepared statement
                        $stmt = $pdo->prepare('INSERT INTO accounts (userToken, firstname, lastname, email, password, creationDate, code) VALUES (?, ?, ?, ?, ?, CURRENT_TIMESTAMP, ?)');
                        $stmt->execute([$userToken, $firstname, $lastname, $email, $hashedPassword, $verificationCode]);

                        // Respond with a success message
                        $response = array('success' => true, 'message' => 'Registration successful', 'userToken' => $userToken);
                    } catch (PDOException $e) {
                        $response = array('success' => false, 'message' => 'Error inserting data into the database');
                    }
                } else {
                    $response = array('success' => false, 'message' => 'Error sending verification email');
                }
            } else {
                $response = array('success' => false, 'message' => 'Email already exists. Please use a different email address.');
            }
        } else {
            $response = array('success' => false, 'message' => 'Passwords do not match');
        }
    } else {
        $response = array('success' => false, 'message' => 'All fields are required');
    }

    // Send JSON response
    header('Content-Type: application/json');
    echo json_encode($response);
}

// Function to handle login API
function login() {
    global $pdo;  // Make $pdo variable available in this function

    // Assuming you receive username and password in the POST request
    $username = isset($_POST['username']) ? $_POST['username'] : null;
    $password = isset($_POST['password']) ? $_POST['password'] : null;

    // Check if both username and password are provided
    if ($username && $password) {
        try {
            // Fetch user information from the database based on the provided username (email)
            $stmt = $pdo->prepare('SELECT id, userToken, firstname, lastname, email, creationDate, password FROM accounts WHERE email = ?');
            $stmt->execute([$username]);
            $user = $stmt->fetch(PDO::FETCH_ASSOC);

            if ($user) {
                // Verify the provided password against the hashed password stored in the database
                if (password_verify($password, $user['password'])) {
                    // User logged in successfully
                    $response = array(
                        'success' => true,
                        'message' => 'Login successful',
                        'user' => array(
                            'id' => $user['id'],
                            'userToken' => $user['userToken'],
                            'firstname' => $user['firstname'],
                            'lastname' => $user['lastname'],
                            'email' => $user['email'],
                            'creationDate' => $user['creationDate']
                        )
                    );
                } else {
                    $response = array('success' => false, 'message' => 'Invalid credentials');
                }
            } else {
                $response = array('success' => false, 'message' => 'User not found');
            }
        } catch (PDOException $e) {
            $response = array('success' => false, 'message' => 'Error retrieving user information');
        }
    } else {
        $response = array('success' => false, 'message' => 'Username and password are required');
    }

    // Send JSON response
    header('Content-Type: application/json');
    echo json_encode($response);
}

?>

I’ve ensured that the SMTP configuration for Gmail is correct in the sendmail function, and I’ve also checked for any exceptions during the email sending process. However, the emails are not being delivered.

I suspect there might be an issue with the SMTP settings or some other configuration. Could someone please review the code and help me identify what might be causing this problem? Are there any common pitfalls with PHPMailer and Gmail SMTP that I might be missing?

Thanks in advance for any assistance!

Create a XML-File from Formdata using php, WordPress

I have a form, and out of the data that are submitted from this form I want to create a XML-File and save this file to a specific path.

I dont know how to pass the data to an php file in WordPress. Usually i would just pass the path of the php file in the action attribute and handle the data.

But how do i do this in WordPress?
I created the form without an plugin.

I am new to WordPress and still try to figure things out.

Thats the Form

<form action="???" method="post">
        
        <input type="hidden" name="action" value="XMLBanf">
        
        <label for="name">Name:</label>
        <input type="text" name="name" required="">

        <label for="departement">Abteilung</label>
        <select name="Abteilung">
            <option value="keine_angabe">Keine Angabe</option>
            <option value="vertrieb">Vertrieb</option>
            <option value="it">IT</option>
            <option value="service">Service</option>
            <option value="lager">Lager</option>
        </select>

        <label for="order">Was soll bestellt werden: </label>
        <textarea name="order" cols="30" rows="10" required=""></textarea>

        <label for="reason_order">Grund der Bestellung</label>
        <input type="text" name="reason_order" required="">

        <label for="price">Angebotspreis</label>
        <input type="number" name="price" required="">

        <label for="offer_file"></label>
        <input type="file">

        <input type="submit" name="submit_button" value="Abschicken">
    </form>

then i would try to handle the data

if(isset($_POST['submit'])){
    $xml = new SimpleXMLElement("<?xml version="1.0" encoding="utf-8" ?><order></order>");

    $xml->addChild('name',$_POST['name']);
    $xml->addChild('departement',$_POST['departement']);
    $xml->addChild('order',$_POST['order']);
    $xml->addChild('reason_order',$_POST['reason_order']);
    $xml->addChild('price',$_POST['price']);

    $fileName = md5(uniqid(mt_rand(), true))."banf.xml";
    $asXML= $xml->asXML();
    $file = fopen($fileName, "w+");
    fwrite($file, $asXML);
    fclose($file);
    print_r(error_get_last());

    if(file_exists("./".$fileName)){
        $myXML = file_get_contents("./".$fileName);
        $xml = new SimpleXMLElement($myXML);
        $xmlpretty = $xml->asXML();

        // pretty print the XML in browser
        header('content-type: text/xml');
        echo $xmlpretty;
    }

How do i access this file now?

Database Connection Issue in cPanel Cron Job

I’m encountering an issue with the execution of a cron job, specifically within cPanel’s cron job setup. When I run the following command with root access in the command line, everything works perfectly, and there are no issues:

/opt/cpanel/ea-php73/root/usr/bin/php -q /home/username1/crmfile/crons/cron.php all -F -vvv >> /home/username1/crondebug.txt

However, when I precisely set the same command in the cPanel cron job setup with the user “username1,” I get the following error in the crondebug.txt file:

<div class="error-container"><h1>Critical Error</h1><p>Could not connect to the database.</p></div>

This title includes additional information to clarify that the website is accessible and functioning correctly, and you have already performed troubleshooting and diagnostics related to WHMCS settings without finding any issues.

‌But this is not working only in cpanel cron job.
How can I resolve this issue?