Columns wont align Horizontally in Bootstrap 5

Im trying to make a Shopping Cart using php and Bootstrap 5. I specified the classes but the items still stacks vertically. I want it to be beside each other and align Horizontally

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>shopping cart</title>
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="cart.css">
</head>
<body>
        <div class="container">

        <?php

        $connect = mysqli_connect('localhost','root','1234','cart');
        $query = 'SELECT * FROM products ORDER by id ASC';
        $result = mysqli_query($connect, $query);

        if ($result) {
            if(mysqli_num_rows($result)>0){
                while($product = mysqli_fetch_assoc($result)){
                    ?>
                  <div class="row">
                    <div class="col-sm-4 col-md-3">
                        <form method="post" action="index.php?action=add&id=<?php echo $product['id']; ?>">
                            <div class="products">
                                <img class="img-fluid" src="<?php echo $product['image']; ?>">
                                <h4 class="text-info"><?php echo $product['name']; ?></h4>
                                <h4>$ <?php echo $product['price'];  ?></h4>
                                <input type="text" name="quantity" class="form-control" value="1" />
                                <input type="hidden" name="name" value="<?php echo $product['name']; ?>"/>
                                <input type="hidden" name="price" value="<?php echo $product['price']; ?>"/>
                                <input type="submit" name="add_to_cart" class="btn btn-info" value="Add to Cart"/>
                            
                            </div>
                        </form>
                    </div>
                    </div>
           
                    <?php 
                }
            }
        }
        ?>
    </div>


    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN" crossorigin="anonymous"></script>
</body>
</html>


is there something that im missing?? I tried evrything that i know of T^T

ps. Im still a novice when it comes to Web Developing so please have mercy on me T^T ;3

How to remove container for menu in Navigation Menu

I have a footer widget that has a Navigation Menu block. I want the wrapper div for the ul to be a nav tag. How can i do this? I tried it with the ‘wp_nav_menu_args’ hook, but it doesn’t work. Although for a header menu made with wp_nav_menu it works.

register_sidebar(array(
  'name' => 'Footer Widget Area',
  'id' => 'footer-widget',
  'description' => 'Footer Widget for blocks',
  'before_widget' => '<div class="footer-content__widget">',
  'after_widget' => '</div>',
));


function my_nav_menu_args($args = '') {

  if ('footer' == $args['theme_location']) {
    if ($args['container'] == 'div') {
      $args['container'] = 'nav';
    }
  }

  return $args;
}

add_filter('wp_nav_menu_args', 'my_nav_menu_args');

Upload big files from nodejs to laravel by file path

I want my electron application (nodejs) to be able to send big files to a php server (laravel). There are several methods which might allow to acheive this mession, like using plupload and resumable.js.
The thing is that I want to load the file by path. In nodejs, it is possible to access files by path using
const stream = fs.createReadStream(file).
However, it is not working for me with the mentioned libraries. In plupload, I tried the following: Uploading a file in electron using plupload programatically
With no answers. This is a separate question, as here I am asking for possible ways to upload large files (using chunks for example) by file path.

i have a problem with my php code, i want to make a spinwheel gift for my business…. can someone help me? when i registered i the echo script show

if (isset($_POST['submit'])) {
    $password = ($_POST['password']);
    $cpassword = ($_POST['cpassword']);
 
    if ($password == $cpassword) {
        $sql = "SELECT * FROM users WHERE password='$password'";
        $result = mysqli_query($conn, $sql);
        if (!$result->num_rows > 0) {
            $sql = "INSERT INTO users (password)
                    VALUES ('$password')";
            $result = mysqli_query($conddn, $sql);
            if ($result) {
                echo "<script>alert('Selamat, registrasi berhasil!')</script>";
                $_POST['password'] = "";
                $_POST['cpassword'] = "";
            } else {
                echo "<script>alert('Woops! Terjadi kesalahan.')</script>";

Not able to Validation data in Yii2 model

I am not able to validate value in model. I am newbie in this can anyone suggest what am I doing wrong. I am working on REST API with excel file upload and validating single row at a time

Here is my data and load data in model

$data = array(
    'firstName' => 'asdjqkw',
    'lastName' => '',
    'email' => 'ansm@',
    'companyName' => 'ddq',
    'address_1' => '',
    'address_2' => 'aas',
    'country' => '',
    'state' => 'New Brunswick',
    'city' => '87875',
    'zip' => '484527',
);
$model->load($data);
if (!$model->validate()) {
    $validation = $model->errors;
}

And here is my model rules and attribute labels as I defined required, email and maxlength validation in it but still some values is available still it is sending required validation error for that field

public function rules() {
    return [
        [['firstName', 'lastName', 'email', 'companyName', 'address_1', 'country', 'state', 'city', 'zip'], 'required'],
        ['email', 'email'],
        [['firstName', 'lastName', 'email', 'companyName', 'address_1', 'country', 'state', 'city', 'zip'], 'string', 'max' => 250],
    ];
}

public function attributeLabels() {
    return [
        'firstName' => 'First Name',
        'lastName' => 'Last Name',
        'email' => 'Email',
        'companyName' => 'Company Name',
        'address_1' => 'Address 1',
        'country' => 'Country',
        'state' => 'State',
        'city' => 'City',
        'zip' => 'Zip',
    ];
}

And I get validation errors after loading this data

"firstName": [
  "First Name cannot be blank."
],
"lastName": [
  "Last Name cannot be blank."
],
"email": [
  "Email cannot be blank."
],
"companyName": [
  "Company Name cannot be blank."
],
"address_1": [
  "Address 1 cannot be blank."
],
"country": [
  "Country cannot be blank."
],
"state": [
  "State cannot be blank."
],
"city": [
  "City cannot be blank."
],
"zip": [
  "Zip cannot be blank."
]

PDOStatement::execute(): SQLSTATE[42000]

I ask for your help because I have been working on an error for 3 days now.

I am trying to create a pagination in php using pdo, but the problem is that I have a Syntax error.

Here is the error:

Warning: PDOStatement::execute(): SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ”-2′,’2” at line 1 in C:wamp64wwwproject12viewspagination.php on line 21

If someone sees where the error is I will be really grateful.

Thanks in advance.

Voici le code source :

<?php
$limit = 2;
$query = "SELECT count(*) FROM employes";
 
$s = DB::connect()->query($query);
$total_results = $s->fetchColumn();
$total_pages = ceil($total_results/$limit);
 
if (!isset($_GET['page'])) {
    $page = 1;
} else{
    $page = $_GET['page'];
}
 
 
 
$starting_limit = ((int)$page-1)*$limit;
$show  = "SELECT * FROM employes ORDER BY id DESC LIMIT ?,?";
 
$r = DB::connect()->prepare($show);
$r->execute([$starting_limit, $limit]);
 
while($res = $r->fetch(PDO::FETCH_ASSOC)):
?>
<h4><?php echo $res['id'];?></h4>
<p><?php echo $res['nom'];?></p>
<hr>
<?php
endwhile;
 
 
for ($page=1; $page <= $total_pages ; $page++):?>
 
<a href='<?php echo "?page=$page"; ?>' class="links"><?php  echo $page; ?>
 </a>
 
<?php endfor; ?>

Remote get featured image from external REST API and add it via .php file

Okay, perhaps the question sounds a bit complicated, but here we go:

I have a single.php file where I get a lot of data from an external API. This works perfectly and I even can get the path to the image I want to set as the featured image for my posts, however: I do not know if and how it is possible to set this featured image with this URL within single.php.

Like, doing:

$response = wp_remote_get( "[path][to][featuredimg]"

I know that there are plugins out there, but is there a way to automate this process within my single.php to create the featured image automatically within that file?

Any help/suggestions?

cgi/fastcgi process – 0% CPU and N% Memory?

I have php wordpress website hosted on IIS, have been using FastCGI, below is my fastCGI configuration

enter image description here

Below is screenshot of task manager
enter image description here

There are many fastCGI processes that are using 0% CPU but consuming certain portion of RAM, is this ok ? or there is any misconfiguration due to which this is happening

I did research online to find reason for same, but did not found anything.

permanently merge and concatenate multiple columns in laravel

I am trying to merge 3 clumns into a single column,

here is the logic:

I have a serial number table with:

  • number
  • prefix
  • separation
    I want to merge them into a single column named serial_number in the same table.

in another table of commands I will recover the serial_number in the controller, at store it will update the number + 1 in the table of serial numbers,

I tried to update the number and concatenate the 3 columns in the controller at each recording it works ,
but the problem is that the user can modify the order of the 3 columns in the settings.

is there a method to permanently merge and concatenate the 3 columns without doing it on the order controller so if the user changes the order automatically it will update the column serial_number ,

get data from postman request with data in body

I have a postman request with some data in the body like that :

{
    "informations" : {
        "contact" :[
        {
    "email" : '[email protected]',
    "phone" : 0111111111,
        }
    ]
    }
}

I symfony side, I can get theses data with :

$data = $request->getContent();
dd($data);

But I can’t access to the “contact” array, I tried this :

dd($data['informations']['contact']);

And I get this error : Warning: Illegal string offset ‘informations’

What is my mistake ? thanks

How to get common key and store value in comma separated in array

Here are the array

“articleCriteria”: [
{
“criteriaId”: 100,
“criteriaDescription”: “Fitting Position”,
“formattedValue”: “Front Axle Right”,
},
{
“criteriaId”: 100,
“criteriaDescription”: “Fitting Position”,
“formattedValue”: “Front Axle Left”,
}
]

iam running foreach loop because other data is also coming but for common key What i want is,

fitting_position = Front Axle Right,Front Axle Left

How to move a uploaded file to a specific drive folder in using Simple Upload in Php cURL?

My requirement is to upload a file to my google drive using Php cURL and then rename the upload file and move the file to a specific folder.

For this, I have done oAuth and successfully uploaded a file from my website to google drive using the below code.

$image = "../../../".$name;
    $apiURL = 'https://www.googleapis.com/upload/drive/v3/files?uploadType=media';
    $mime_type = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
    $folder_id = "1WBkQQ6y0TPt2gmFR3PKCzSip_aAuuNEa";
    
    $ch1 = curl_init();    
    curl_setopt($ch1, CURLOPT_URL, $apiURL);
    curl_setopt($ch1, CURLOPT_BINARYTRANSFER, 1);
    curl_setopt($ch1, CURLOPT_POST, 1);
    curl_setopt($ch1, CURLOPT_POSTFIELDS, file_get_contents($image));
    curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch1, CURLOPT_HTTPHEADER, array('Content-Type: '.$mime_type, 'Authorization: Bearer ' . $access_token) );
    // execute cURL request
    $response=curl_exec($ch1);
    if($response === false){
        $output = 'ERROR: '.curl_error($ch1);
    } else{
        $output = $response;
    }
    // close first request handler
    curl_close($ch1);
    $this_response_arr = json_decode($response, true);

The file is uploaded as Untitled and I used the below code to rename it to a proper filename as per my requirement.

 if(isset($this_response_arr['id'])){
        $this_file_id = $this_response_arr['id'];
        $ch2 = curl_init();
        curl_setopt($ch2, CURLOPT_URL, 'https://www.googleapis.com/drive/v3/files/'.$this_file_id);
        curl_setopt($ch2, CURLOPT_CUSTOMREQUEST, 'PATCH');
        $post_fields = array();
        $this_file_name = explode('.', $name);
        $post_fields['name'] = $this_file_name[0];
        curl_setopt($ch2, CURLOPT_POSTFIELDS, json_encode($post_fields));
        curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch2, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Authorization: Bearer ' . $access_token) );
        $response2 = curl_exec($ch2);
        if($response2 === false){
            $output2 = 'ERROR: '.curl_error($ch2);
        } else{
            $output2 = $response2;
        }
       
        curl_close($ch2);
        $this_response2 = json_decode($response2, true);
        }

Now I want to move this uploaded file in the Google drive root folder to a specific folder. I tried using “Parents” , “addParents”, “removeParents” parameters but none of them is working.

        if($this_response2['id']){
        $this_f_id = $this_response2['id'];
$ch3 = curl_init();
curl_setopt($ch3, CURLOPT_URL, 'https://www.googleapis.com/drive/v3/files/'.$this_f_id);
curl_setopt($ch3, CURLOPT_CUSTOMREQUEST, 'PATCH');
curl_setopt($ch3, CURLOPT_POST, 1);
$post_fields1 = array();
$post_fields1['addParents'] = $folder_id;
$post_fields1['removeParents'] = "root";
curl_setopt($ch3, CURLOPT_POSTFIELDS, json_encode($post_fields1));
curl_setopt($ch3, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch3, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Authorization: Bearer ' . $access_token) );
$response3 = curl_exec($ch3);
if($response3 === false){
    $output3 = 'ERROR: '.curl_error($ch3);
} else{
    $output3 = $response3;
}
curl_close($ch3);

}

Any help would be appreciated.

Compare values using strpos – PHP

I am trying to return the user_id if value matches with any comma separated value, I am using strpos but I don’t why is it not working with 3rd case:

To Compare: (This value is stored in $myArray variable)

Array
(
    [0] => cloud
    [1] => ai
    [2] => test
)

Compare with: (This value is stored in $array_meta_values variable)

Array
(
    [0] => Array
        (
            [tags] => cloud,ai
            [user_id] => 1
        )

    [1] => Array
        (
            [tags] => cloud,ai,test
            [user_id] => 108
        )

    [2] => Array
        (
            [tags] => storage,backup,ai
            [user_id] => 101
        )

)



function searchForId($meta_value, $array)
{

    foreach ($array as $key => $val) {
        if (strpos($val['tags'], $meta_value)) {
            return $val['user_id'];
        }
    }
}

foreach ($myArray as $usertags) {
        $userids[] = searchForId($usertags, $array_meta_values);
    }
print_r($userids);

Getting this Output:

Array
(
    [1] => 1
    [2] => 108
)

It was supposed to add 101 as third element in output array but don’t know why it is not working.

Any help appreciated.

Laravel, MariaDB timestamp column without default and onupdate trigger

I have following migration:

Schema::create('auctions', function (Blueprint $table) {
    $table->id();
    $table->timestamp('expired_at');
    $table->timestamp('sold_at')->nullable()->default(null);
    // other fields
});

Which creates a table with this structure:
enter image description here

Every time I try to update sold_at field only, It changes the expire_at field also, which is so annoying and against my project’s logic! How should I fix my migration to prevent this?

My update record code:

Auction::query()->where('id',1)->update([
    'sold_at' => now()
]);