Got error ‘PHP message: PHP Parse error: syntax error, unexpected ‘Config’ (T_STRING) on line 19 [duplicate]

AH01071: Got error ‘PHP message: PHP Parse error: syntax error, unexpected ‘Config’ (T_STRING) in /pay/enot_end.php on line 19′

<?php

    include "enot/config.php";
    
    $MERCHANT_ID = Config::merchant_id;
    $SECRET_WORD = Config::secret_key;
    $ORDER_AMOUNT = $_REQUEST['amount'];
    $ORDER_ACCOUNT = $_REQUEST['custom_field'];
    $PAYMENT_ID = $_REQUEST['merchant_id'];
    
    $sign = md5($MERCHANT_ID.':'.$ORDER_AMOUNT.':'.$SECRET_WORD.':'.$PAYMENT_ID);
    $link = mysqli_connect(Config::host, Config::user, Config::pass, Config::base);
    
    if(!$link)
        die('Error Connect: ' . mysqli_error());
    
    if($sign != $_REQUEST['sign_2']) 
        die('bad sign!');
    
    $sql = "UPDATE `"Config::t_account"` SET `"Config::t_account_name"`="Config::t_account_donate"+".$amount." WHERE "Config::t_account"='".$ORDER_ACCOUNT."'";
    
    if(mysqli_query($link, $sql)) 
        echo "Records were updated successfully.";
    else echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
    
    mysqli_close($link);
    
    echo "Good";
?>

PHP 8.3 from source, mysqli.so not found

I’ve compiled php8.3 from source in ubuntu 20.04 server.
The installation process is

./configure --prefix=/home/ubuntu/php8.3 --enable-zts --with-mysqli --disable-fileinfo --with-openssl --with-zlib --with-curl --enable-pcntl  --enable-mysqlnd
make -j4
sudo make install

I’ve copied php.ini-production to /home/ubuntu/php8.3/lib/php.ini and enabled extension=mysqli in it.
But when I run /home/ubuntu/php8.3/bin/php -v I get

PHP Warning:  PHP Startup: Unable to load dynamic library 'mysqli' (tried: /home/ubuntu/php8.3/lib/php/extensions/no-debug-zts-20220830/mysqli (/home/ubuntu/php8.3/lib/php/extensions/no-debug-zts-20220830/mysqli: cannot open shared object file: No such file or directory), /home/ubuntu/php8.3/lib/php/extensions/no-debug-zts-20220830/mysqli.so (/home/ubuntu/php8.3/lib/php/extensions/no-debug-zts-20220830/mysqli.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

I’ve checked /home/ubuntu/php8.3/lib/php/extensions/no-debug-zts-20220830/ and inside I’ve only opcache.so

Output of is /home/ubuntu/php8.3/bin/php -m

[PHP Modules]
Core
ctype
curl
date
dom
filter
hash
iconv
json
libxml
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_sqlite
Phar
posix
random
Reflection
session
SimpleXML
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
zlib

[Zend Modules]

So the question is, where is mysqli.so? What I’m wrong?

Thanks to all

Doctrine: how to describe manyToOne relation with composite key and update cascade?

I have a table that has composite primary key: id + est_date. And it has an entity:

class Parent
{
    /**
     * @ORMId
     */
    private $id;

    /**
     * @ORMId
     */
    private int $estDate;
...
}

Now I need to create a related table and its entity.

class Child
{
...
    /**
     * don't know what to write here
     */
    private $parentId;

    /**
     * don't know what to write here
     */
    private int $parentEstDate;
...
}

How to discribe relation ManyToOne (many “Child” entities may relate to 1 “Parent”)? And the second issue is – “estDate” of the “Parent” may change. How to specify cascade update in “Child”?
Please don’t write that doctrine doesn’t recomment to use composite keys. I know that.

odbc DSN string for MS Access DB works only with php5.4 [duplicate]

i’m trying to connect to an old Access database (c:content.mdb) using the odbc driver Microsoft Access Driver (*.mdb) version 10.00.22624.01 (installed from this link: https://www.microsoft.com/en-us/download/details.aspx?id=13255).

The connection string i’m using is the following: Driver={Microsoft Access Driver (*.mdb)};DBQ=C:content.mdb; Uid=; Pwd=;

If i try to connect with an ancient php version (php v5.4.45, which has odbc extension v1.0), everything is fine.

If i try to connect with a “modern” php version (php v8.1.12 with odbc extension v8.1.12) or any DBMS supporting odbc (eg DBeaver v22.2.4, which uses jdbc:odbc), i get the following error:

SQLSTATE[IM002] SQLDriverConnect: 0 [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

The connection string (hence the odbc driver used) is exactly the same. Using php’s PDO or odbc_* functions yields the same results.

So why is this happening? Why does it work with php 5.4 but fails with anything else?

Nginx reverse proxy always returns old response from php api proxy

I have an issue with my Nginx reverse proxy where I have two servers one is front and the other is a back-end API, and I want when I visit the front (https://front.com/urn) it will proxy the request to the back (https://back.com/urn) but at the same time I want my front domain name to be seen in the backend so I’m using this directive

  proxy_set_header Host $host;

when I add this directive is when the problem appear, it looks like the response changed to an old response, which I don’t get why is that happening, I’m assuming is cache.

this Nginx config works properly

server_name front.com;

location / {
  proxy_pass http://localhost:4500;
  proxy_http_version 1.1;
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection 'upgrade';
  proxy_set_header Host $host;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_cache_bypass $http_upgrade;
}

location /urn {
  proxy_pass https://back.com;
}

but when I use this directive “proxy_set_header Host $host;” I always get old response

server_name front.com;

location / {
  proxy_pass http://localhost:4500;
  proxy_http_version 1.1;
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection 'upgrade';
  proxy_set_header Host $host;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_cache_bypass $http_upgrade;
}

location /urn {
  proxy_pass https://back.com;
  proxy_set_header Host $host;
}

this is the api function that is called with https://back.com/urn/$param

public function testDownload(Request $request, $param)
{
    dump($param);
    dd($request);
}

I tried disabling the cache but I feel like I don’t understand where the problem comes from, and I don’t know where to look for the source of the problem.

proxy_cache_bypass: 1

Please if you can tell me why this is happening and probably how can i fix it, thank you so much.

PHP Doctrine connect to MSSQL server v11 drops auth exception

I want to connect an MS-SQL server v11.0.700 using Doctrine. The user I have to use exists on the SQL server as user with “SQL Authentication”.

What I do is:

$modelPath = __DIR__."/../model";
$config = ORMSetup::createAttributeMetadataConfiguration(
    paths: array($modelPath),
    isDevMode: true,
);

$conn = array(
    'driver'   => "pdo_sqlsrv",
    'host'     => "sqlserver1",
    'user'     => "myUser",
    'password' => "fancyPwdHere123",
    'dbname'   => "testDatabase",
);

$entityManager = EntityManager::create($conn, $config);

The result is is:

PHP Fatal error:  Uncaught PDOException: SQLSTATE[28000]: 
  [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Login failed for user 'myUser'. 
  in E:PHPDoctrine-ORMvendordoctrinedbalsrcDriverPDOSQLSrvDriver.php:42
    Stack trace:
    #0 E:PHPDoctrine-ORMvendordoctrinedbalsrcDriverPDOSQLSrvDriver.php(42): PDO->__construct()
    #1 E:PHPDoctrine-ORMvendordoctrinedbalsrcConnection.php(346): DoctrineDBALDriverPDOSQLSrvDriver->connect()
    #2 E:PHPDoctrine-ORMvendordoctrinedbalsrcConnection.php(1619): DoctrineDBALConnection->connect()
    #3 E:PHPDoctrine-ORMvendordoctrinedbalsrcConnection.php(1013): DoctrineDBALConnection->getWrappedConnection()
    #4 E:PHPDoctrine-ORMtryIt.php(7): DoctrineDBALConnection->prepare()
    #5 {main}

The user name and password is good (double checked). My PHP is 8.1.11, and composer.json content is:

{
    "require": {
        "doctrine/orm": "^2.11.0",
        "doctrine/dbal": "^3.2",
        "symfony/yaml": "^5.4",
        "symfony/cache": "^5.4"
    },
    "autoload": {
        "psr-0": {"": "src/"}
    }
}

    

Any advice why this happens and how to resolve the login problem? Thanks in advance!

How to store order data from shopify webhooks in mysql database using php?

I want to use shopify order webhook to store order data into mysql database. I am beginner in webhooks. Googled many times to find the guidance about how to achieve it.I found this solutions is very close for me.I wrote the php code but I am getting error like thiserror image.I don’t know why I am getting this error and how to resolve it.Please suggest us.

I followed these steps

  1. I created the webhook from shopify admin dashboard
  2. Point the webhook to my own domain
  3. And write the following code in the pointed link
    here is my code

my code is

<?php
$webhook_content = NULL;

 // Get webhook content from the POST
 $webhook = fopen('php://input' , 'rb');
 while (!feof($webhook)) {
 $webhook_content .= fread($webhook, 4096);
 }

 fclose($webhook);

 // Decode Shopify POST
 $webhook_content = json_decode($webhook_content, TRUE);

$servername = "localhost";
$database = "xxxxxxxx_xxxhalis"; 
$username = "xxxxxxxx_xxxhalis";
$password = "***********";
$sql = "mysql:host=$servername;dbname=$database;";

 // Create a new connection to the MySQL database using PDO, $my_Db_Connection is an object
 try { 
  $db = new PDO($sql, $username, $password);
  //echo "<p> DB Connect = Success.</p>";
 } catch (PDOException $error) {
  echo 'Connection error: ' . $error->getMessage();
 }
    $order_num= $webhook_content['name'];
    $order_date = $webhook_content['created_at'];
    $order_mode = "Online";
    $location= $webhook_content['default_address']['province'];
    $cust_name = $webhook_content['billing_address']['name'];
    $address = $webhook_content['default_address']['address1']['address2']['city']['province']['zip'];
    $phone_num = $webhook_content['default_address']['phone'];
    
    $special_note= $webhook_content['note'];
    $total_mrp = $webhook_content['current_subtotal_price'];
    $total_discount= $webhook_content['current_total_discounts'];
    $sub_total = $webhook_content['current_subtotal_price'];
    $delivery_charges = $webhook_content['presentment_money']['amount'];
    
    $totalOrderValues= $webhook_content['total_price'];
    $discount_approval = "NA";
    $invoice_status= "NA";
    $punching_status = "NA";
    $order_source = "Shopify";
    
    $payment_mode= $webhook_content['payment_gateway_names'];
    $payement_status = "Done";
    $payement_recieve_date= $webhook_content['processed_at'];
    $reference_number = $webhook_content['reference'];
    $cash_handover_status = "NA";

$my_Insert_Statement = $my_Db_Connection->prepare("INSERT INTO `customer_order_sab`( `order_num`, `order_datetime`, `modeOfOrder`, `location`, `customer_name`, `address`, `phone_number`, `special_note`, `total_mrp`, `total_discount`, `sub_total`, `delivery_charges`, `totalOrderValues`, `discount_approval`, `invoice_status`, `punching_status`, `order_source`, `payment_mode`, `payement_status`, `payement_recieve_date`, `reference_number`, `cash_handover_status`) VALUES (:order_num, :order_date, :order_mode, :location, :cust_name, :address, :phone_num, :special_note, :total_mrp, :total_discount, :sub_total, :delivery_charges, :totalOrderValues, :discount_approval, :invoice_status, :punching_status, :order_source, :payment_mode, :payement_status, :payement_recieve_date, :reference_number, :cash_handover_status)");

$my_Insert_Statement->bindParam(':order_num', $order_num);
$my_Insert_Statement->bindParam(':order_date', $order_date);
$my_Insert_Statement->bindParam(':order_mode', $order_mode);
$my_Insert_Statement->bindParam(':location', $location);
$my_Insert_Statement->bindParam(':cust_name', $cust_name);
$my_Insert_Statement->bindParam(':address', $address);
$my_Insert_Statement->bindParam(':phone_num', $phone_num);
$my_Insert_Statement->bindParam(':special_note', $special_note);
$my_Insert_Statement->bindParam(':total_mrp', $total_mrp);
$my_Insert_Statement->bindParam(':total_discount', $total_discount);
$my_Insert_Statement->bindParam(':sub_total', $sub_total);
$my_Insert_Statement->bindParam(':delivery_charges', $delivery_charges);
$my_Insert_Statement->bindParam(':totalOrderValues', $totalOrderValues);
$my_Insert_Statement->bindParam(':discount_approval', $discount_approval);
$my_Insert_Statement->bindParam(':invoice_status', $invoice_status);
$my_Insert_Statement->bindParam(':punching_status', $punching_status);
$my_Insert_Statement->bindParam(':order_source', $order_source);
$my_Insert_Statement->bindParam(':payment_mode', $payment_mode);
$my_Insert_Statement->bindParam(':payement_status', $payement_status);
$my_Insert_Statement->bindParam(':payement_recieve_date', $payement_recieve_date);
$my_Insert_Statement->bindParam(':reference_number', $reference_number);
$my_Insert_Statement->bindParam(':cash_handover_status', $cash_handover_status);
if ($my_Insert_Statement->execute()) {
  echo "New record created successfully";
} else {
  echo "Unable to create record";
}



?>

PHP: how to realize a server for multipart/form-data post request

I need to create a server for a multipart / form-data post request submit that sends me a file, and since I have no control over the client side I wanted to know how to receive the file without knowing the name of the field containing the file, in practice the client side is not my property but I still have to receive files from the outside. How can I intercept the request? I have to do everything in php. Is there a way to make a post request by sending a file without a form in php? Although virtually the client sending me the file could be written in any language

To test i wrote a form to send the file in html, I know the form is correct but I don’t know how to intercept the request and read the file server side without referring to the name of the input field

<form action='https://DNS:443/context/NomeComponente?<parametro1>=<valore1>&<parametro2>=<valore2>&…&<parametroN>=<valoreN>' method='post' enctype='multipart/form-data'>
            <div class='row'>
                <div class='col-25'>
                    <label for='country'>select file to upload</label>
                </div>
                <div class='col-75'>
                    <input type='file' name='fileToUpload' id='fileToUpload'>
                </div>
            </div>
            <div class='row'>
                <br>
                <center><input type='submit' value='Upload file' name='submit'></center>
            </div>
        </form>

display value information inside a function? [closed]

How to output information about the value (1) in var_dump,
What is specified to search in str_contains?

$a = 1;
$b = str_contains($a, 1);  //value 1 for which to show information in var_dump

echo var_dump($b);        // prints bool(true) and not information about the value 1, 
                          // which is specified in the search 
                         

Issues with Null field in MariaDB 10.6.11 [closed]

I recently bought a server with latest cPanel and Maria Db installed but nearly all PHP scripts are throwing null error..

This errors are ignored in MariaDB 10.3.35 which was the previous version i was using.

I’ve been setting the column as “Null” or modifiying the code to accomodate to null and this works but the error is just much and i will like a one time solution for all.

I am considering downgrading mariadb or installing v 10.3 along with it, I don’t know if this will work though as i ve not try such before.

Pls note, this error occurs on previous site that was moved from the old server and also on new php script i want to install (although the coding looks old).

Thanks in anticipation

How to categorise xml api output by Division

I am working in Codeigniter project where i need to show vacancies category wise from api results.

I have XML output like this

<Vacancy ID="1">
    <VacancyID>1</VacancyID>
    <Division ID="1">Div 1</Division>
    // Other Data
</Vacancy>
<Vacancy ID="2">
    <VacancyID>2</VacancyID>
    <Division ID="2">Div 2</Division>
    // Other Data
</Vacancy>
<Vacancy ID="3">
    <VacancyID>3</VacancyID>
    <Division ID="1">Div 1</Division>
    // Other Data
</Vacancy>

I want to categorise vacancies by division so i want to convert this into something like

<Division ID="1">
   <Vacancy ID="1">
      <VacancyID>1</VacancyID>
      <Division ID="1">Div 1</Division>
      // Other Data
   </Vacancy>
   <Vacancy ID="3">
      <VacancyID>3</VacancyID>
      <Division ID="1">Div 1</Division>
      // Other Data
   </Vacancy>
</Division>
<Division ID="2">
   <Vacancy ID="2">
      <VacancyID>2</VacancyID>
      <Division ID="2">Div 2</Division>
      // Other Data
   </Vacancy>
</Division>

How can i achieve this?

Laravel Passport Grant Token — Set custom username and password fields

I am working on project which has separate model for users — AppModelsCustomer. And also it has own authorisation fields — Email and cust_password. And also password is hashed by password_hash function.

In my config/auth.php in providers section I set up my custom model:

'providers' => [
    'customers' => [
        'driver' => 'eloquent',
        'model' => AppModelsCustomer::class,
    ],
],

So I am trying to implement Laravel Grand Tokens. I need to make request to /oauth/token/ with client (which was previously created with custom provider field) and customer credentials as like this:

/** @var LaravelPassportClient $client */

$response = Http::asForm
    ->post('https://localhost/oauth/token/', [
        'grant_type' => 'password',
        'client_id' => $client->id,
        'client_secret' => $client->secret,
        'username' => '[email protected]',
        'password' => password_hash('my-password'),
    ]);

But I am receiving error: invalid_grant — The user credentials were incorrect.

I assume that Passport doesn’t know where to find my Email and cust_password fields. Is there any way to set custom login and password fiends?

Thanks you any advice!

Need to change Custom Page name in WordPress from “services” to “products”

Have a wordpress Website in development a theme which has following url for a services

url for custom page type :
localhost/website/service/mechanical-engineering/
localhost/website/service/automotive-parts-systems/

need to change it to :
localhost/website/product/mechanical-engineering/
localhost/website/product/automotive-parts-systems/

I am not able to change it in permalinks, also i am a designer and know little about php

Have tried changing page name and tags in permalinks
also not able to find any plugin which can do this

Base64 decoded image is corrupted when sending to S3 bucket

I have a base64 image and I will send it to amazon S3 but when it is uploaded the jpeg is 0kb in size and it is corrupted.
by the way I am using AWS SDK for PHP.

Here is my PHP code:


`<?php
include ‘multi-step/connection.php’;
require ‘../vendor/autoload.php’;

$image = $_POST['image'];
$studentID = date("Y"). '-' .mt_rand();

$image_parts = explode(";base64,", $image);
$image_type_aux = explode("image/", $image_parts[0]);
$image_type = $image_type_aux[1];
$image_base64 = $image_parts[1];

$decodedImage = base64_decode($image_base64);


$args = [
    'credentials' => [
        'key' => '<KEY>',
        'secret' => '<SECRET KEY>',
    ],
    'region' => 'ap-southeast-1',
    'version' => 'latest'
];

use AwsS3S3Client;

try{

$sdk = new AwsSdk($args); /*Instantiate SDK class with configs for API use*/

$s3Client = $sdk->createS3(); /*creates the S3 Client for API use*/

$key = 'i-attend-faces/' .$studentID. '/facereference.jpeg';

/*print_r($_FILES['file']);*/
$result = $s3Client->putObject([
    'Bucket' => 'iattendfacebucket',
    'Key' => $key,
    'Body' => $decodedImage,
    'ContentType'=> 'image/jpeg',
]);
echo "FILE SENT";
echo $result;
}catch(Exception $e){
echo $e;
}`

I tried decoding it and then place it in the Body but it is also corrupted.