update query with concat in mysql using php

public function UpdateMyTask($Request,$user_id)
{
  $Query='';
  //$Request['ip_addr']=$_SERVER['REMOTE_ADDR'];
    //$Request['user_agent']=$_SERVER['HTTP_USER_AGENT'];
   // $user_agent= strlen(stristr($_SERVER['HTTP_USER_AGENT'],"Mobile"))?"Mobile":strlen(stristr($_SERVER['HTTP_USER_AGENT'],"Windows"))?"Windows":"Android" ; 
   if(strlen(stristr($_SERVER['HTTP_USER_AGENT'],"Mobile")))
{
  $user_agent="Mobile";
}else if(strlen(stristr($_SERVER['HTTP_USER_AGENT'],"Windows")))
{
  $user_agent="Windows";
}else if(strlen(stristr($_SERVER['HTTP_USER_AGENT'],"Android")))
{
  $user_agent="Android";
}
foreach($Request as $Index => $Value)
{
     if($Index == 'task_id')
    {
        $task_id= ($Value);
    }
	$Query.=$Index."='".mysqli_real_escape_string($this->link,$Value)."',";
}
$Query= rtrim($Query,',').",update_date_time=concat(update_date_time,',','".date('H:i')."'),ip_addr=concat(ip_addr,',','".$_SERVER['REMOTE_ADDR']."'),user_agent=concat(user_agent,',','".$user_agent."') where task_id='".$task_id."' and user_id='".$user_id."'";
$Query="update mytask set ".$Query;
	
		$result=$this->NonQuery($Query);
	
		return $result ;
	
}

calculate hours between two times in php

  $difference=0;
                if($task[$i]['in_date_time'] && $task[$i]['out_date_time']){
                $expiry_time = new DateTime($task[$i]['in_date_time']);
                $current_date = new DateTime($task[$i]['out_date_time']);
                $diff = $expiry_time->diff($current_date);
                $difference= $diff->format('%H:%I'); 
                }            
                 echo $difference;

php code for generating qr code | It’s worth adding that, in addition to the QR codes library posted by Google

It’s worth adding that, in addition to the QR codes library posted by Google

To use this , basically:

https://chart.googleapis.com/chart?chs=300x300&cht=qr&chl=http%3A%2F%2Fwww.google.com%2F&choe=UTF-8
  • 300x300 is the size of the QR image you want to generate,
  • the chl is the url-encoded string you want to change into a QR code, and
  • the choe is the (optional) encoding.

The link, above, gives more detail, but to use it just have the src of an image point to the manipulated value, like so:

<img src="https://chart.googleapis.com/chart?chs=300x300&cht=qr&chl=http%3A%2F%2Fwww.google.com%2F&choe=UTF-8" title="Link to Google.com" />

Demo:

php code for generating qr code | HP QR Code is open source (LGPL) library for generating

PHP QR Code is open source (LGPL) library for generating QR Code, 2-dimensional barcode. Based on libqrencode C library, provides API for creating QR Code barcode images (PNG, JPEG thanks to GD2). Implemented purely in PHP, with no external dependencies (except GD2 if needed).

Some of library features includes:

  • Supports QR Code versions (size) 1-40
  • Numeric, Alphanumeric, 8-bit and Kanji encoding. (Kanji encoding was not fully tested, if you are japan-encoding enabled you can contribute by verifing it 🙂 )
  • Implemented purely in PHP, no external dependencies except GD2
  • Exports to PNG, JPEG images, also exports as bit-table
  • TCPDF 2-D barcode API integration
  • Easy to configure
  • Data cache for calculation speed-up
  • Provided merge tool helps deploy library as a one big dependency-less file, simple to “include and do not wory”
  • Debug data dump, error logging, time benchmarking
  • API documentation
  • Detailed examples
  • 100% Open Source, LGPL Licensed

WordPress 404 page redirect to homepage

Open 404.php file from theme in theme editor in WordPress

This code match string from URL and redirect to specific url, this should be the first line in 404.php file.

<?php if(strstr($_SERVER['REQUEST_URI'],"abc")){ header('location:http://typing.soatechnology.net/index.php'); }  get_header();?>

language value print in Laravel blade

<?php

// resources/lang/en/messages.php

return [
    'welcome' => 'Welcome to our application!',
];
echo __('messages.welcome');
{{ __('messages.welcome') }}

@lang('messages.welcome')

Laravel language file contains array



<?php

// resources/lang/en/messages.php

return [
  'month'=>array("जनवरी","फरवरी","मार्च","अप्रैल","मई","जून","जुलाई","अगस्त","सितम्बर","अक्टूबर","नवम्बर","दिसम्बर"),
];

{{ __('message.month.1') }}

set timezone in laravel 8

edit file /config/app.php and change value of timezone

'timezone' => 'Asia/Dhaka'

Using Environment file (.env)

Inside env
add DB config
DB_TIMEZONE=+08:00

AH01079: failed to make connection to backend: httpd-UDS

In order to fix this issue we need to restart the improved PHP handler ( ea-php72-php-fpm.service )

# systemctl restart ea-php72-php-fpm.service

It seems there is an issue with PHP-FPM mode (Mod-PHP works fine).
I installed version p3 on CentOS 6.5 succesfully and works OK.

Email : adityaypi@yahoo.com, Mobile : +91-9555699081

If problem exists, remove PHP-FPM module

FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation with some additional features (mostly) useful for heavy-loaded sites.

These features include:

  • advanced process management with graceful stop/start;
  • ability to start workers with different uid/gid/chroot/environment, listening on different ports and using different php.ini (replaces safe_mode);
  • stdout and stderr logging;
  • emergency restart in case of accidental opcode cache destruction;
  • accelerated upload support;
  • “slowlog” – logging scripts (not just their names, but their PHP backtraces too, using ptrace and similar things to read remote process’ execute_data) that are executed unusually slow;
  • fastcgi_finish_request() – special function to finish request and flush all data while continuing to do something time-consuming (video converting, stats processing etc.);
  • dynamic/static child spawning;
  • basic SAPI status info (similar to Apache mod_status);
  • php.ini-based config file.

Laravel seo hack trick

header.blade.php

  <!doctype html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">


    @yield('seo')


    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
   <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
  <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/dt/dt-1.10.18/datatables.min.css"/>
<script type="text/javascript" src="https://cdn.datatables.net/v/dt/dt-1.10.18/datatables.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
{{-- san San-Francisco Font --}}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/mailtoharshit/San-Francisco-Font-/sanfrancisco.css">
  <link rel="stylesheet" href="{{ asset('/index.css') }}">
  

    <!-- <link rel="stylesheet" href="{{ asset('/homejs.js') }}"> -->
    <title>Aditya Kumar Singh</title>
  </head>
  <body>
  <nav class="navbar navbar-expand-lg navbar-red navbar-dark p-0">
    <!-- <div class="wrapper"> </div> -->
    <div class="container-fluid"> <a class="navbar-brand p-0" href="/">
     
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>
  <div class="collapse navbar-collapse" id="navbarSupportedContent">
    <ul class="navbar-nav mr-auto ml-auto">

                <li class="nav-item"> <a class="nav-link mr-4 " aria-current="page" href="/">Home</a> </li>
                <!-- <li class="nav-item"> <a class="nav-link mr-4" href="#">Features</a> </li> -->
                <li class="nav-item"> <a class="nav-link mr-4" href="/about" call_type="About">About us</a> </li>
                <!-- <li class="nav-item"> <a class="nav-link mr-4" href="#">Fees</a> </li> -->
                <li class="nav-item"> <a class="nav-link mr-4" href="/contact" call_type="Contact">contact us</a> </li>
                <!-- <li class="nav-item"> <a class="nav-link mr-4" href="#"><i class="fa fa-search"></i></a> </li> -->
            </ul>
            <!-- <div class="d-flex flex-column sim"> <a class="btn btn-light action-button" role="button" href="#">Sign Up <i class="fa fa-arrow-right"></i></a> </div> -->
        </div>
    </div>
</nav>
   
  @yield('content') 
  @yield('footer')

index.blade.php

@extends('header')
@section('seo')
<title>Aditya kumar singh</title>
<meta name="description" content="aditya kumar singh">
<meta name=”robots” content="index, follow">
@endsection
  @section('content') 


<!-- HTML TAG -->

@endsection
@extends('footer')

contact.blade.php

@extends('header')
@section('seo')
<title>Aditya kumar singh</title>
<meta name="description" content="aditya kumar singh">
<meta name=”robots” content="index, follow">
@endsection
  @section('content') 
  <section id="contact" style="background-color:#f5f5f5">
<div class="container py-5">
	<div class="row justify-content-center align-items-center">
		<div class="col-12 col-sm-12 col-md-10 col-lg-10">
    
      <form action="/add-contact " method="post">
      @csrf
      <div class="text-center py-4"><h3 class="display-4 bold orange">Contact Us</h3>
                                </div>
                                @if ($message = Session::get('success'))
        <div class="alert alert-success">
            <p>{{ $message }}</p>
        </div>
    @endif
                                <div class="row" style="margin:0px 0px">
                                <div class="col-lg-6 col-md-6 col-sm-6" style="padding-bottom: 10px;">
                                <label for="name" class="mb-2"><b>Name</b></label>
                                <input class="form-control shadow p-4 mb-4 bg-white rounded @error('name') is-invalid @enderror" name="name" placeholder="Marth Wanjiku" type="text" />
                                @error('name')
<div class="alert alert-danger mt-1 mb-1">{{ $message }}</div>
@enderror
  </div>
                                <div class="col-lg-6 col-md-6 col-sm-6" style="padding-bottom: 10px;">
                                <label for="email" class="mb-2"><b>Email</b></label> 
                                 <input class="form-control shadow p-4 mb-4 bg-white rounded @error('email') is-invalid @enderror" name="email" placeholder="what's your email?" type="text"  />
                                 @error('email')
<div class="alert alert-danger mt-1 mb-1">{{ $message }}</div>
@enderror
   </div>
                                </div>
                                <div class="col-lg-12 col-md-12 col-sm-12" style="padding-bottom: 10px;">
                                <label for="msg" class="mb-2"><b>Massage</b></label>
                                <textarea rows="6" name="message" id="message2" class="form-control shadow p-4 mb-4 bg-white rounded @error('message') is-invalid @enderror" placeholder="How Can Help You?" ></textarea> 
                                @error('message')
<div class="alert alert-danger mt-1 mb-1">{{ $message }}</div>
@enderror
   </div>
                                <div class="btn-left">
                                   <input type="submit" name="sent" value="SUBMIT" class="btn btn-info btn-block rounded-0 py-2">
                                </div>
</div>
                    </form>
	  </div>
  </div>
</div>
</section>

  @endsection
@extends('footer')

Laravel 8 migrate specific table

php artisan migrate --path=/database/migrations/fileName.php
php artisan migrate --path=/database/migrations/2020_04_10_130703_create_test_table.php
php artisan migrate:refresh --path=/database/migrations/2021_06_23_093317_create_users_table.php
To rollback one step:

php artisan migrate:rollback

To rollback multiple steps:

php artisan migrate:rollback --step=[x]
  
To drop all tables and reload all migrations:

php artisan migrate:fresh