How to create signature for twitter api

I’m trying to create a signature for the twitch api, but I don’t know what’s wrong

$this->timestamp = time();
$this->nonce = mt_rand();

    $base = 'POST' . "&" . rawurlencode('https://api.twitter.com/1.1/statuses/update.json') . "&" . rawurlencode('include_entities=true&')
        . rawurlencode("oauth_consumer_key=" . rawurlencode($this->consumer_key)
            . "&oauth_nonce=" . rawurlencode($this->nonce)
            . "&oauth_signature_method=" . $this->oauth_signature_method
            . "&oauth_timestamp=" . $this->timestamp
            . "&oauth_token=" . $this->access_token
            . "&oauth_version=" . $this->oauth_version
            . "&status=Hello%20Ladies%20%2b%20Gentlemen%2c%20a%20signed%20OAuth%20request%21"
        );

    dump("base string");
    dump($base);

    $key = rawurlencode($this->consumer_secret) . '&' . rawurlencode($this->token_secret);
    $this->signature = base64_encode(hash_hmac('sha1', $base, $key, true));

mysql delete rows using NOT IN with multiple columns

I’ve been trying to delete rows in a table where NOT IN php array.

basically, the table contains table_1_id, table_2_id, is_active

So my query is :

$delete = "
    DELETE FROM pivot
    WHERE (table_1_id, table_2_id) 
    NOT IN (
        ".implode(',', array_unique($table1Ids)).", 
        ".implode(',', array_unique($table2Ids))."
    ) AND is_active = 1
";

However, this query deletes all the rows EITHER table_1_id‘s value not in $table1Ids or table_2_id‘s value not in $table12ds.

I expected it to delete rows, STRICTLY to compare both table_1_id and table_2_id at the same time, not EITHER.

Sorry for bad explanation, seems too hard to put into words.

Installing Magento2 by command lin on MacOS – Error with command bin/magento setup:install

So I am trying to install Magento 2 for the first time on my new MacBook I have everything setup except for installing with the setup command bin/magento setup:install

I created a database and a user with privileges to that database with the mysql command, but after I run:

--base-url='http://127.0.0.1/magento2' 
--db-host='localhost' 
--db-name='magento2' 
--db-user='nick' 
--db-password='root' 
--admin-firstname=admin 
--admin-lastname=admin 
[email protected] 
--admin-user=admin 
--admin-password=admin123 
--language=en_US 
--currency=USD 
--timezone=America/Chicago 
--use-rewrites=1

I get this error message:

SQLSTATE[HY000] [1045] Access denied for user ‘nick’@’localhost’ (using password: YES)

In InstallCommand.php line 274:

Parameter validation failed

Since I have never installed Magento 2 on my own I don’t know what to do.
Oh yeah and I am using MAMP as server with Apache port 80 and MySQL port 3306

Set span to Shopify liquid Variable

I am trying to set span class “price” to Liquid variable if the if statement is true.

<p class="old-price"><span class="price-sep"></span><span class="price"></span></p>

I have tried this method to see if this “price” class in the if statement overrides the “price” class above because it comes after the above code. I’m new to Liquid but I know in JavaScript there is a way you can set text to “variable”, what is the way with Liquid ?

{% if dynamic_products.compare_at_price_max > dynamic_products.price %}
                <p class="old-price"><span class="price-sep"></span><span class="price">Box 
Value:{{ dynamic_products.compare_at_price | money }}</span></p>

How to download a file directly instead of reading it from the html

i have this code:

        $garages = $this->formatGaragesData($garageEntities);
        // Returns an array with multiple arrays in it which are containing values like name etc

        $fileName = 'garage_export.csv';

        header('Content-Type: application/csv');
        header('Content-Disposition: attachment; filename="' . $fileName . '"');
        header("Content-Transfer-Encoding: UTF-8");

        foreach ($garages as $garage) {
            foreach ($garage as $value) {
                echo $value;
            }
        }

this downloads my garage_export.csv file but it does not place the values in the correct columns, so i thought is there a way to download garage_export.csv directly instead of reading it from the html because in garage_export.csv the data is placed in the correct columns.

Any help or advice is welcome 😀

How to show the data properly in the table

hi i have an php code which is read an json field value and displayed in the table format my code is working fine but the data is not arranged properly how to fix this one can anyone help me on this

 $post_id = get_the_ID();

$dataproducts = get_field( “data_product”, $post_id);
$data = json_decode($dataproducts);

$table = '
<table class="company-sub-table">
<colgroup>
<col>
<col>
<col>
<col>
</colgroup>
<thead>
<tr>
    <th>Name</th>
    <th>Description</th>
    <th>Uses Data Product</th>
    <th>Customer Type</th>
</tr>
</thead>
<tbody>
';
foreach ($data as $dataproducts_var) {
  foreach ($dataproducts_var->name as $name_of_dp)
  {
 
  echo "<script>console.log('Console: " . $name_of_dp . "' );</script>";
    $name_dp = $name_of_dp;
  echo "<script>console.log('Console: " . $name_dp . "' );</script>";
    $table .= '
        <tr>
            <td>' . $name_dp . '</td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
    ';
}
    
    foreach ($dataproducts_var->description as $description)
    {
        $description_to_print = $description;
        $table .= '
            <tr>
                <td></td>
                <td>' . $description_to_print . '</td>
                <td></td>
                <td></td>
            </tr>
            ';
    }
    foreach ($dataproducts_var->uses_data_product as $uses_dp)
    {
        $uses_dp_to_display = $uses_dp;
        $table .= '
            <tr>
                <td></td>
                <td></td>
                <td>' . $uses_dp_to_display  . '</td>
                <td></td>
            </tr>
            ';
    }
    foreach ($dataproducts_var->customer_type as $c_type)
    {
        $c_type_to_display = $c_type;
        $table .= '
            <tr>
                <td></td>
                <td></td>
                <td></td>
                <td>' . $c_type_to_display . '</td>
            </tr>
            ';
    }
}
$table .= '
    </tbody>
</table>
';
echo $table;

this is the table looks like

this is the json field value———- [{“name”:[“JDLink “],”description”:[“Solution that fits any make/model of equipment, including older John Deere and non-John Deere equipment. Places essential machine information such as location, machine hours, and alerts at the usersu2019 fingertips, leaving them in complete control to increase machine productivity.”],”uses_data_product”:[“GPS Data, Equipment/Maintanence Data”],”customer_type”:[“Vehicle Fleet Operators”]},{“name”:[“Granular Insights”],”description”:[“John Deere’s telematics system supports operational improvements by providing information such as field ops data like hours, acres and quantities of inputs applied, and crops harvested. Premium services are sold at 6$ per Acre. “],”uses_data_product”:[“Farm Yeild Data”],”customer_type”:[“Farmers”]}]

Email Sending Issue on nginx Server

I have shifted my website to a new Nginx server with PHP 7.4, Apache 2.4, and OpenSSL 1.1.1n. If I try to send an email from default PHP settings it sends the email successfully but it will go to spam/junk which is fine with me. We use ZohoMail and Office365 on different cpanel accounts.

$mail->Encoding = "base64";
$mail->SMTPAuth = true;
$mail->Host = "smtppro.zoho.com";
$mail->Port = 465;
$mail->Username = '[email protected]';
$mail->Password = 'yourpassword';
$mail->SMTPSecure = 'SSL';
$mail->isSMTP();
$mail->IsHTML(true);
$mail->CharSet = "UTF-8";
$mail->From = "[email protected]";
$mail->FromName = 'Company';
$mail->addAddress('[email protected]');
$mail->Body="Test email sent successfully.";
$mail->Subject="Test Email";
$mail->SMTPDebug = 1;
$mail->Debugoutput = function($str, $level) {echo "debug level $level; message: $str"; echo "<br>";};
if(!$mail->Send()) {
    echo "Mail sending failed";
} else {
    echo "Successfully sent";
}

The server is not accepting any SMTP settings but the default PHP email works. Please guide me to solve this issue as I’m new to nginx servers.

symfony asset-component in controller: file not found

I’m using Symfony 5.3.9 and try to load a file into a Service-controller.
I use the assets-component with emptyVersionStrategy.

my filesystem:

/assets/vorlagen/XXX.html

My Service-Controller-Code:

$package = new PathPackage('/assets/vorlagen', new EmptyVersionStrategy());
$template = $package->getUrl($anzeige->getTemplate()->getDatei());
$handle = file_get_contents($template);

The error-Message:
Warning: file_get_contents(/assets/vorlagen/XXX.html): failed to open stream: No such file or directory

When I simply return $anzeige->getTemplate()->getDatei() the name of the file is correct
and

Eclipse PHP to work with Javascript syntax

I am looking for a plugin of some sort that would help with the highlighting of JavaScript elements and syntax within Eclipse 2022-03 (4.23.0). Currently using the IDE for PHP development proposes and want to ensure that whatever plugins have already been installed dont mess up my current IDE settings/customizations.
I have looked for various plugins (Sonarlint being the highest rating, but wont install) but no luck so far.

Any help with this would be highly appreciated.
Cheers

Converting a Time from a database to BST with PHP

So I’ve trying all sorts of combinations to get a date from my database (using WordPress) to display in British Summer Time and I cannot get anything to work.

Is there any simple solution that can take the date string and make sure that in Summer Time in the UK it’s an hour on from UTC time?

$classJson = $class->info;
$classJsonAsArray = json_decode($classJson, TRUE);

$classStartDate = strtotime($class->periodStart);
$classStartTime = date('H:i',$classStartDate);

So currently $class->periodStart returns: 2022-04-06 08:30:00

The time of that event should be 9.30am

All I need it to do is display the correct time, as at the moment, on the front end it displays as 8.30am.

Fatal error: Uncaught PDOException: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in php:74 [duplicate]

 if(isset($_POST["create_invoice"]))
  { 
    $sub_total = 0;
    $discount = 0;
    $total_after_discount = 0;

    $statement = $conn->prepare("
      INSERT INTO tbl_medlab 
        (order_no, order_date, order_receiver_name, order_receiver_address, sub_total, discount, total_after_discount,order_datetime)
        VALUES (:order_no, :order_date, :order_receiver_name, :order_receiver_address, :sub_total, :discount, :total_after_discount, :order_datetime)
    ");
    $statement->execute(
      array(
          ':order_no'               =>  trim($_POST["order_no"]),
          ':order_date'             =>  trim($_POST["order_date"]),
          ':order_receiver_name'          =>  trim($_POST["order_receiver_name"]),
          ':order_receiver_address'       =>  trim($_POST["order_receiver_address"]),

          ':sub_total'       =>  $sub_total,
          ':discount'           =>  $discount,
          ':total_after_discount'        =>  $total_after_discount,
          ':order_datetime'           =>  date("Y-m-d")
      )
    );

  $statement = $conn->query("SELECT LAST_INSERT_ID()");
      $order_id = $statement->fetchColumn();

      for($count=0; $count<$_POST["total_item"]; $count++)
      {
        $sub_total = $sub_total + floatval(trim($_POST["order_item_actual_amount"][$count]));


        $discount = $discount + floatval(trim($_POST["discount_amount"][$count]));

        $total_after_discount = $total_after_discount + floatval(trim($_POST["order_item_final_amount"][$count]));

        $statement = $conn->prepare("
          INSERT INTO tbl_medlab_item 
          (order_id,item_type, item_name, order_item_quantity, order_item_price, order_item_actual_amount, discount, discount_amount, order_item_final_amount)
          VALUES (:order_id, :item_type, :item_name, :order_item_quantity, :order_item_price, :order_item_actual_amount, :discount, :discount_amount, :order_item_final_amount)
        ");

        $statement->execute(
          array(
            ':order_id'               =>  $order_id,
            ':item_name'              =>  trim($_POST["item_name"][$count]),
            ':order_item_quantity'          =>  trim($_POST["order_item_quantity"][$count]),
            ':order_item_price'           =>  trim($_POST["order_item_price"][$count]),
            ':order_item_actual_amount'       =>  trim($_POST["order_item_actual_amount"][$count]),

            ':discount'         =>  trim($_POST["discount"][$count]),
            ':discount_amount'       =>  trim($_POST["discount_amount"][$count]),
//ERROR PART START HERE
            ':order_item_final_amount'      =>  trim($_POST["order_item_final_amount"][$count]) 
//ERROR PART END'S HERE
          )
        );
      }
      $total_after_discount = $sub_total - $discount ;

      $statement = $conn->prepare("
        UPDATE tbl_medlab 
        SET sub_total = :sub_total, 
        discount = :discount, 
        total_after_discount = :total_after_discount 
        WHERE order_id = :order_id 
      ");
      $statement->execute(
        array(
          ':sub_total'     =>  $sub_total,
          ':discount'         =>  $discount,
          ':total_after_discount'      =>  $total_after_discount,
          ':order_id'             =>  $order_id
        )
      );
      header("location:md_sale.php");
  }

I am getting an error part on line 74:

Fatal error: Uncaught PDOException: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in C:xampphtdocsSanRem MD LABmd_sale.php:74 Stack trace: #0 C:xampphtdocsSanRem MD LABmd_sale.php(74): PDOStatement->execute(Array) #1 {main} thrown in C:xampphtdocsSanRem MD LABmd_sale.php on line 74

I already exhausted all the possible fixes but it is always showing that error.

I was expecting for it to save the data to the database after I click on Create Invoice but then this error show up.

create tracking like feature using laravel and mysql?

Hope this question doesn’t get downvotes as it is little theoretical and it is a feature enabled in my application which is of real time racing appliccation.

In this application admin creates races and set some route and racers play those races with their mobile as they must have our product app.

Now what I am going to explain is we have created our own tracking feature for our admins in which admin can see the current positions of all the racers and for that we have done this implementation

there was a api which recieves user location in every 2-3 seconds and those records are stored in Database
(mysql database,INNODB)

and these are the field which i stored

{
"latitude":"",
"longitude":"",
"timestamp":""
"bearingAngle":"",
"currentSpeed":""
}

in my location table and for currentlocation i used to query my users latest location according to time and from that i was able to create current location tracking

one more feature which i introduced was complete tracing of users in which i use all the locations stored in DB and create a KML (Keyhole markup language) file by which complete track is visible to admin which racer has used for that race.

This was working fine but when the races increased the DB load gradually increased and day after day my tracking performance decreased as there were so much data and querying that data my db performance went down ….

For that i switched my implementations and instead of storing location data into DB
i stored those location data in txt files in this format

latitude|longitude|timestamp|bearingAngle|currentSpeed
latitude|longitude|timestamp|bearingAngle|currentSpeed
latitude|longitude|timestamp|bearingAngle|currentSpeed
latitude|longitude|timestamp|bearingAngle|currentSpeed
.
.
.
.
.

and stored only the latest location on table
from now i can get the current location from the tables and for tracing part i can use my files

this implementation reduced my load on DB and my performance also improved on backend level

Now there is no such code to debug but it is a architecture which i want to create and also created and at my own I did my best to optimize this implementation but somewhere in my mind there is some doubt that might be this implementation can be done more efficiently and I just want some ideas that how can i achieve this implementation more better.

Hope my problem is understood and again I am repeating this is not code level issue it is just a implentation improvement.

Thank you !!!