PHP Call to undefined function $name = call_user_func [closed]

Hello i have this issue but im not figured out why

Error: Call to undefined function Wachat() in /home/hexahos4/public_html/modules/addons/wachat/classes/WachatGateway.php:112
Stack trace:

#0 /home/hexahos4/public_html/modules/addons/wachat/controller/WhatsAppConfig.php(70):WachatGateway::GatewayList()

#1 /home/hexahos4/public_html/modules/addons/wachat/base.php(30): WhatsAppConfig->index()

#2 /home/hexahos4/public_html/modules/addons/wachat/wachat.php(156):require(‘/home/hexahos4/…’)

#3 /home/hexahos4/public_html/lakonage/addonmodules.php(0): wachat_output(Array)

#4 {main}

93. public static function GatewayList()
94.    {
95.        if(!function_exists("moduleConfigFieldOutput")) {
96.            require_once ROOTDIR . "/includes/modulefunctions.php";
97.        }
98.        if(is_dir(ROOTDIR . "/modules/addons/wachat/classes/")) {
99.            $handle = opendir(ROOTDIR . "/modules/addons/wachat/gateways/");
100.            $return_array = [];
101.            while ($file = readdir($handle)) {
102.                $file = str_replace(".php", "", $file);
103.                if($file != "index") {
104.                    $modfilename = ROOTDIR . "/modules/addons/wachat/gateways/" . $file . ".php";
105.                    if(is_file($modfilename)) {
106.                        if(!function_exists("gateway_" . $file . "_send")) {
107.                            require $modfilename;
108.                        }
109.                        if(function_exists("gateway_" . $file . "_send")) {
110.                            $name = $file;
111.                            if(function_exists("gateway_" . $file . "_name")) {
112.                                $name = call_user_func("gateway_" . $file . "_name")();
113.                            }
114.                            $return_array[$file] = $name;
115.                        }
116.                    }
117.                }
118.            }
119.            return $return_array;
120        }
121.    }

Gateway Wachat.php

<?php
function gateway_wachat_name()
{
    return "Wachat";
}
function gateway_wachat_config()
{
    $configarray = ["apikey" => ["FriendlyName" => "API Token", "Type" => "text", "Description" => "API Token];
    return $configarray;
}
function gateway_wachat_send($params)
{

How to set OCI 8 in Servbayy PHP

I already change extension oci8 php.ini in servbay configuration but still cant turn on OCI 8,

is there any package that i shoulde be download and install to use OCI8 in servbay php

Laravel 11 Passport installation failed

I encountered the following error while trying to install laravel/passport. I’ve already added extension=sodium to my php.ini file and attempted to install the package using the command:

composer require laravel/passport:^11.0

However, I still receive the same error. I also tried installing paragonie/sodium_compat_ext_sodium, but that did not resolve the issue.

Here’s the error message:

Problem 1
- Root composer.json requires laravel/passport 12.0 -> satisfiable by laravel/passport[v12.0.0].
- laravel/passport v12.0.0 requires lcobucci/jwt ^4.3|^5.0 -> satisfiable by lcobucci/jwt[4.3.0, 5.0.0, ..., 5.5.0].
- lcobucci/jwt[4.3.0, 5.1.0, ..., 5.5.0] require ext-sodium * -> it is missing from your system. Install or enable PHP's sodium extension.
        
Alternatively you can require one of these packages that provide the extension (or parts of it):
- paragonie/sodium_compat_ext_sodium
- juspay/expresscheckout-php-sdk Express Checkout SDK for PHP allows easy integration with Juspay's EC payments as a service platform  
- vufind/vufind A flexible discovery layer.

- lcobucci/jwt 5.0.0 requires php ~8.1.0 || ~8.2.0 -> your php version (8.3.14) does not satisfy that requirement.

To enable extensions, verify that they are enabled in your .ini files:
- C:wamp64binphpphp8.3.14php.ini
You can also run `php --ini` in a terminal to see which files are used by PHP in CLI mode.
Alternatively, you can run Composer with `--ignore-platform-req=ext-sodium` to temporarily ignore these required extensions.

Moreover, I’ve verified that I’m editing the correct php.ini file located at:

C:wamp64binphpphp8.3.14php.ini

I also ran php --ini to confirm the active configuration files. Despite this, the sodium extension is still not detected. I’ve attached my composer.json screenshot for reference.

As per feedback, i have downgrade my php version to 8.2. And now i encounter the following error

Here is the message:

Problem 1
    - Root composer.json requires laravel/passport 11.0 -> satisfiable by laravel/passport[v11.0.0].
    - laravel/passport v11.0.0 requires illuminate/auth ^9.0 -> found illuminate/auth[v9.0.0, ..., v9.52.16] but these were not loaded, likely because it conflicts with another require.

same laravel_session value, but not the same value

i’m using laravel 12 and try to use middleware to check the user is login or not.

I set the session value in api Controller, but, when I call this value in middleware, it will be null.
and my log only show the token in session.
how to get session value correctly?

my laravel_session in header and session value in database:
laravel_session=fca6d3xPRfTdlHBSTJWBd0KvaieSdKPbcGkFBZxa

a:3:{s:6:"_token";s:40:"0hYLgh1hHAZNW2Ar8E6MDBP5zKJXlLynSjt4dgTp";s:4:"user";s:5:"admin";s:6:"_flash";a:2:{s:3:"old";a:0:{}s:3:"new";a:0:{}}}

i’m use the session function to set global session value.
i’m sure that name is not null.

        // loginVerify
        $validate = $request->authenticate();

        if ($validate) {
            $post = $request->post()['body'];
    
            $acct = User::where([['email', '=', $post['acct']],['password', '=', $post['ps']]])->first();
            session(['user' => $acct['name']]);
            return $acct;
        }

log not show user value in my session

my session value: {"_token":"T9EtbOAiUwUYc9s1l1gC4TrdSkTj8nT9SDFbqTIA"}

    // middleware managePage
    public function handle(Request $request, Closure $next): Response
    {
        Log::debug ('my session value: ' . json_encode(session()->all()));
        dd($request->header('Cookie'));
        if (empty(session('user'))) {
            return redirect('/managerLogin');
        }
        return $next($request);
    }

here is my middleware setting:

        $middleware->prependToGroup('manageSetting', [
            IlluminateSessionMiddlewareStartSession::class,
        ]);
        $middleware->appendToGroup('managePage', [
            ManagerPage::class,
        ]);

and this is my route setting:

// web route
Route::middleware(['manageSetting', 'managePage'])->group(function () {
    Route::get('/homeManage', function () {
        return Inertia::render('manage/homeManage');
    });
    Route::get('/groupManage', function () {
        return Inertia::render('manage/groupManage');
    });
});
Route::middleware(['manageSetting'])->group(function() {

    Route::get('/managerLogin', function () {
        return Inertia::render('manage/login');
    })->name('managerlogin');
});

//api route
Route::middleware(['manageSetting'])->group(function () {
    Route::post('/updateGroup', [GroupController::class, 'update']);
    Route::post('/updateHome', [KeyVisualController::class, 'update']);
    Route::post('/loginVerify', [UserController::class, 'login']);
});

How to submit radio button attendance status for multiple students in PHP?

I’m working on a PHP project where I need to mark student attendance. I’ve already fetched the students from the database based on their class and section, and displayed them in a table. Each row has a student’s name and two radio buttons — one for Present and one for Absent.

My main challenge is:
How can I structure the radio button inputs and handle the form submission in PHP to store each student’s attendance status in the database?

<tr>
    <td class="text-center">
        <?php echo($no++);?>
    </td>
    <td class="text-center">
        <?php echo($studentId); ?>
    </td>
    <td class="text-center">
        <?php echo($studentName); ?>
    </td>
    <td class="text-center">
        <?php echo($fullClassName); ?>
    </td>
    <td class="text-center">
        <?php echo($attType); ?>
    </td>
    <td class="text-center">
        <label for="">Pre</label>
        <input type="radio" value="">
        <label for="">abs</label>
        <input type="radio" value="">
    </td>
</tr>

What I want to achieve:
When the form is submitted, loop through the attendance input in PHP.

Insert the attendance into a database table with fields like:

student_id

teacher_id

status (present or absent)

date

Convert nested array to multiple flat arrays

I don’t found here a solution for my problem. Because of this, here my issue:
I have an array of some parameters (like a YAML config file) and this need to be written to database finaly with primary ids and so on.

For example this is a part of my array:

$settings = [
'basic' => [                       // first level category
    'installation_type' => [       // setting parameter with parameter attributes
        'type' => '["single","cluster"]',
        'description' => 'bla blah',
        'readonly' => false,
        'hidden' => false,
        'trigger' => null,
        'default' => 'single'
    ],
    'db_master_host' => [
        'type' => 'ip',
        'description' => 'Database hostname or IP',
        'default' => 'localhost'
    ],
    'db_master_user' => [
        'type' => 'text',
        'description' => 'Database username',
        'default' => 'test'
    ],
    'db_master_pwd' => [
        'type' => 'secret',
        'description' => 'Database user password',
    ],
    'db_master_db' => [
        'type' => 'text',
        'description' => 'Database name',
        'default' => 'test'
    ]
],
'provisioning' => [         // first level category
    'snom' => [             // second level category
        'snom_prov_enabled' => [
            'type' => 'switch',
            'default' => false
        ],
        'snom_m3' => [
            'snom_m3_accounts' => [
                'type' => 'number',
                'description' => 'bla blah',
                'default' => '0'
            ]
        ],
        'snom_dect' => [
            'snom_dect_enabled' => [
                'type' => 'switch',
                'description' => 'bla blah',
                'default' => false
            ]
        ]
    ],
    'yealink' => [
        'yealink_prov_enabled' => [
            'type' => 'switch',
            'default' => false
        ]
    ]
],

];

As result I need some arrays like images of database tables (category, setting, value) with self-generated IDs:

$category["basic"] = [id: 1, parent: 0, name: "basic", order: 1]
$setting["installation_type"] = [id: 1, catId: 1, name: "installation_type", type: '["single","cluster"]', desc: 'asd', order: 1]
$value["installation_type"] = [id: 1, setId: 1, default: 'single']
$setting["db_master_host"] = [id: 2, catId: 1, name: "db_master_host", type: 'ip', desc: 'asd', order: 2]
$value["db_master_host"] = [id: 2, setId: 2, name: "db_master_host", default: 'localhost']
...
$category["provisioning"] = [id: 2, parent: 0, name: "provisioning", order: 2]
$category["snom"] = [id: 3, parent: 2, name: "snom", order: 3]
...

I hope my problem is understandable here and anyone could help me.

im getting this error when i run this comand: php artisan migrate. Answer below in the link [duplicate]

SQLSTATE[HY000]: General error: 1005 Can’t create table madhhab.issues (errno: 150 “Foreign key constraint is incorrectly formed”) (Connection: mysql, SQL: alter table issues add constraint issues_subchapter_id_foreign foreign key (subchapter_id) references subchapters (id) on delete cascade)

i droped the table from database then run the commands php artisan migrate:rollback
php artisan migrate:fresh , php artisan migrate:refresh

enter code here

All these and i dont know how i can fix it
i tried some of the answers form stakoverflow but didnt work

im expecting just to migrate the tables and start the work im stuck in this error for hoursss

// Your code goes here
public function up() {
    Schema::create('issues', function (Blueprint $table) {
        $table->id();
        $table->text('title_ar');
        $table->text('title_sq');
        $table->timestamps();
    });
}

   public function up(): void
    {
        Schema::create('subchapters', function (Blueprint $table) {
            $table->id();
            $table->foreignId('chapter_id')->constrained('chapters')->onDelete('cascade');
            $table->string('title_ar');
            $table->string('title_sq');
            $table->integer('display_order');
            $table->timestamps();
        });

    }

Answer:
link

Exclude variable data if not found

How do I write my controller code below so that if $find is not present in Other OE Referances (the Data in the table is a string), then exclude?

I get that I potentially need to run Other OE Referances through a loop to separate them, and then check, but I also have a feeling I am overthinking.

Controller Snippet:

$find = 'G060162A2';

$letsFind = DB::table('parts')
            ->where('OE Number', '=', $find)
            ->orWhere('Other OE Referances', '=', $find)
            ->get();

Database:

object(stdClass)#584 (4) {
  ["ID"]=>
  int(23)
  ["internal ID"]=>
  string(6) "160980"
  ["OE Number"]=>
  string(9) "G060162A2"
  ["Other OE Referances"]=>
  string(37) "83222152426 ,83222289720, 83222305397"
}

remove XML from SOAP responses

I am trying to deploy a non-wsdl php soapserver, the code as follows if very basic:

function notify($string) {
    return null;
 }
 
$server = new SoapServer(null,
            array('uri' => "http://localhost/"));

$server->addFunction("notify");
   $server->handle(); 

The above seems to work fine, the only problem is that the soap client requires a 200 OK and empty notifyResponse XML element. As you can see from the above, I tried a “return null” on the notify function but that still builds a “notifyResponse” element.

Unfortunately I cannot modify the client to accept anything different. I also tried removing the soapServer for tests and generated a http response with just a 200ok without any XML response and that was acceptable, unfortunately I cannot find a way to do this when soapServer is used.

The most simplified response I was able to generate is shown below, I achieved that by using:

return new SoapVar(”,XSD_ANYXML);

But this is still not accepted by the client as a good response, I either need to remove the whole XML layer or at least remove the “notifyResponse”

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
                   xmlns:ns1="http://localhost/"
                   xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                   xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
                   SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
  <SOAP-ENV:Body><ns1:notifyResponse></ns1:notifyResponse></SOAP-ENV:Body>
</SOAP-ENV:Envelope>




Finding the bit depth of an image

I have some images with different formats (jpg, webp, png, …). I’m coding a script (in php) to gather some infos from these images (like dimensions, resolution, bit-depth and …).
Since with php built-in functions, just for jpg format (and maybe another format), it’s possible to obtain bit-depth property of an image; I tried Imagick functions to do so.
I tried this:

        $image = new Imagick($tmpName);
        $colorspace = $image->getImageColorspace();
        $bitsPerChannel = $image->getImageDepth();
        $channels = 0;
        switch ($colorspace) {
            case Imagick::COLORSPACE_SRGB:
                $channels = 3;
                break;
            case Imagick::COLORSPACE_CMYK:
                $channels = 4;
                break;
            case Imagick::COLORSPACE_GRAY:
                $channels = 1;
                break;
        }
        
        if ($image->getImageAlphaChannel()) {
            $channels += 1; // add alpha
        }
        
        $totalBitsPerPixel = $bitsPerChannel * $channels;

But the value of $totalBitsPerPixel is different with “bit-depth” property which Windows shows in “Properties” of image.

I searched stackoverflow, googled all kind of functions, chatted with Sider(chrom), but couldn’t find the reason of this.
What I’m looking for is: Windows shows a bit-depth property for each image file. How to acquire that in php?
Giving advice would be appreciated.
I attached a sample image:

enter image description here

TablesColumnsIconColumns use a fn call to alternate icons depending on value but uses LIKE, would like to use a LIKE or CONTAINS

I am using Filament admin panel in Laravel.
Filament v3.3.14, Laravel 12x

I have found this great little function to alternate my icons depending on the value (0 or 1).

             TablesColumnsIconColumn::make('paid')
                ->icon(fn (string $state): string => match ($state) {
                    '1' => 'heroicon-o-check-circle',
                    '0' => 'heroicon-o-x-circle',
                })

I would like to use it on a different function with text values as below:

TablesColumnsIconColumn::make('test_value')
                ->icon(fn (string $state): string => match ($state) {
                    'high' => 'heroicon-o-check-circle',
                    'medium' => 'heroicon-o-x-circle',
                    'low' => 'heroicon-o-x-circle',
                    'extreme' => 'heroicon-o-x-circle',
                })

But the test_value will often end up with values like “Medium (12)” or “Extreme (25)”.

Is there a way to loosen up the string match? Similar to a LIKE or CONTAINS?

I cannot locate any direction out in the wide yonder internet.
Would greatly appreciate if you have any suggestions.

Error establishing a database connection in localhost WordPress instance [duplicate]

I feel as though I did everything that I possibly could to try to get this connection to work, but it’s still not working and I don’t know where the problem could be.

I am using MAMP and have been using it for a while, but for some reason I’ve been having database connection problems recently out of nowhere. I never changed anything in MAMP until now, and now it feels as though nothing I do works.

I got the phpMyAdmin to work by changing the port number for MYSQL and Apache and adding the MYSQL port number at the end of the hostname in the config.inc.php: $cfg['Servers'][$i]['host'] = 'localhost:3310';.

When adding the new hostname to wp-config.php, it’s giving me this error:
Localhost database connection error for my website

Here is the hostname in my wp-config file: define( 'DB_HOST', 'localhost:3310' );. I also checked my firewall settings in my Mac to be sure it’s off and it is. I checked root username login info and all of it matched and I tried creating a new database user and that also didn’t solve the issue.

Any help to solve this is appreciated.

How to get closest multiple input fields value in jQuery ajax

The table have multiple items like (apple, mango, orange) i want to get the qty table data closest multiple input values on separate inputs. But i receive only single input value from it. So i can’t send it in ajax properly. I am trying to get multiple input values of closest table row but i get only one value from it.

Any help will be appreciated.

<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Mutiple Qty Values</title>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" charset="utf-8"></script>
</head>
<body>
<div class="alertContainer"></div>
<table>
    <thead>
        <tr>
            <td>Id</td>
            <td>Item</td>
            <td>Qty</td>
            <td>Action</td>
        </tr>
        <tbody>
            <form method="post">
            <tr>
                <td>1</td>
                <td>apple</td>
                <td>
                    <input type="hidden" name="multi_qty[]" value="10" class="qty">
                    <input type="hidden" name="multi_qty[]" value="20" class="qty">
                </td>
                <td><button type="submit" name="delete_qty" class="deleteBtn">Delete</button></td>
            </tr>
            <tr>
                <td>2</td>
                <td>mango</td>
                <td>
                    <input type="hidden" name="multi_qty[]" value="40" class="qty">
                    <input type="hidden" name="multi_qty[]" value="50" class="qty">
                </td>
                <td><button type="submit" name="delete_qty" class="deleteBtn">Delete</button></td>
            </tr>
            <tr>
                <td>3</td>
                <td>orange</td>
                <td>
                    <input type="hidden" name="multi_qty[]" value="70" class="qty">
                    <input type="hidden" name="multi_qty[]" value="80" class="qty">
                </td>
                <td><button type="submit" name="delete_qty" class="deleteBtn">Delete</button></td>
            </tr>
            </form>
        </tbody>
    </thead>
</table>
<div class="result">
    <input type="text" class="input_result">
    <input type="text" class="input_result">
</div>
<script>
  $(document).ready(function(){ 
    $('.deleteBtn').click(function(e){ 
      e.preventDefault();
      var qtyValue = $(this).closest('tr').find('.qty').val();
      $('.input_result').val(qtyValue);

     // ajax code start
      var inputResult = $('.input_result').val();
      $.ajax({
        url:'delete-item.php',
        type:'post',
        data:'inputResult='+inputResult,
        success:function(result){
            $('.alertContainer').html('item deleted');
        }
      })
    })
})
</script>

PHPCS Warning: Incorrect number of replacements in $wpdb->prepare() with dynamic IN clause

I’m working on a WordPress plugin and keep getting a PHPCS warning that I can’t seem to resolve. The warning is:

WARNING WordPress.DB.PreparedSQLPlaceholders.ReplacementsWrongNumber
Incorrect number of replacements passed to $wpdb->prepare(). Found 3 replacement parameters, expected 2. 

Here’s my code snippet:

// Check for image URL or filename in postmeta
if ($attachment_url) {
$attachment_basename = basename($attachment_url);

// Prepare the status placeholders
$placeholders = implode(',', array_fill(0, count($statuses), '%s'));

$meta_url_usage = $wpdb->get_var(
    $wpdb->prepare(
        "SELECT COUNT(*) 
        FROM $wpdb->postmeta pm
        JOIN $wpdb->posts p ON p.ID = pm.post_id
        WHERE (pm.meta_value LIKE %s OR pm.meta_value LIKE %s)
        AND p.post_status IN ($placeholders)",
        '%' . $wpdb->esc_like($attachment_url) . '%',
        '%' . $wpdb->esc_like($attachment_basename) . '%',
        ...$statuses
    )
);

if ($meta_url_usage > 0) {
    return true;
}

What I’ve tried:

  1. Verified that $statuses is a non-empty array
  2. Confirmed the generated SQL looks correct when printed
  3. The query actually works in execution
  4. Tried different placeholder approaches for the IN clause

Problem is PHPCS thinks I should only have 2 replacements (for the LIKE clauses). But I need to pass the status values for the IN clause. The spread operator (…$statuses) is adding additional parameters.

My Question: Is this a false positive in PHPCS or am I doing something wrong? What’s the proper way to handle dynamic IN clauses with $wpdb->prepare()? Or, should I suppress the Warning?

The code works as expected, but I want to make sure I’m following WordPress coding standards properly. Any insights would be greatly appreciated!

symfony ORM mapping any expert please help me or I will hit my head on wall

I am mapping one to many relation. I have a product entity under which there will be multiple features but I am getting this error and now I am frustrated here
error: Unrecognized field: AppEntityProduct: :$product (500 Internal Server Error)
this error is raising while calling the API
below is the relevant files contents

calling file

/**
 * @Route("/api/products/{id}/features", name="Features_list", methods={"GET"})
 */
public function featuresList(int $id, EntityManagerInterface $em): JsonResponse
{
    $product = $em->getRepository(Product::class)->find($id);
    if (!$product) {
        return new JsonResponse(['message' => 'No product found'], 404);
    }
    // print_r($product);exit();
    $features = $em->getRepository(Feature::class)->findBy([
        'product' => $product,
        'deleted' => 0 
    ]);

    if (!$features) {
        return new JsonResponse(['message' => 'No features found'], 404);
    }

Feature.php

/**
 * @ORMManyToOne(targetEntity="AppEntityProduct", inversedBy="features")
 * @ORMJoinColumn(name="product_id", referencedColumnName="id", nullable=false, 
   onDelete="CASCADE")
 */
private $product;

Product.php

/**
 * @ORMOneToMany(targetEntity="AppEntityFeature", mappedBy="product", orphanRemoval=true, cascade={"persist", "remove"})
 */
private $features;

/**
 * @return Collection|Feature[]
 */
public function getFeatures(): Collection
{
    return $this->features;
}

public function addFeature(Feature $feature): self
{
    if (!$this->features->contains($feature)) {
        $this->features[] = $feature;
        $feature->setProduct($this);
    }

    return $this;
}

public function removeFeature(Feature $feature): self
{
    if ($this->features->removeElement($feature)) {
        if ($feature->getProduct() === $this) {
            $feature->setProduct(null);
        }
    }

    return $this;
}