Display php mysql data column with group by sum

I want to generate report in phpmysql in such a way that first detail rows display and in the bottom , sum of that detail row display on the basis of group by statement.

Select id, 
       Emp-name,  
       department, 
       salary, 
       sum(salary) as total sum for each dept
from Employee 
group by department

SIMPLESAMLPHP Redirect loop with valet

I am setup the SimpleSAMLphp setup using Laravel Valet but I am stuck in redirect loop following is my config setting. Please anybody help what did I wrong. when I try to open the page its ask me to many redirect loop.

Array
(
[baseurlpath] => http://sso.test/public
[application] => Array
(
[baseURL] => http://sso.test
)

[tempdir] => /tmp/simplesaml
[certdir] => cert/
[technicalcontact_name] => XXXXX
[technicalcontact_email] => XXXXXX.com
[timezone] => 
[secretsalt] => 12345654321122
[auth.adminpassword] => 123
[trusted.url.domains] => Array
    (
    )

[trusted.url.regex] => 
[enable.http_post] => 
[assertion.allowed_clock_skew] => 180
[debug] => Array
    (
        [saml] => 1
        [backtraces] => 1
        [validatexml] => 
    )

[showerrors] => 1
[errorreporting] => 1
[logging.level] => 5
[logging.handler] => syslog
[logging.facility] => 168
[logging.processname] => simplesamlphp
[logging.logfile] => simplesamlphp.log
[statistics.out] => Array
    (
    )

[proxy] => 
[database.dsn] => mysql:host=localhost;dbname=saml
[database.username] => simplesamlphp
[database.password] => secret
[database.options] => Array
    (
    )

[database.prefix] => 
[database.driver_options] => Array
    (
    )

[database.persistent] => 
[database.secondaries] => Array
    (
    )

[enable.saml20-idp] => 
[enable.adfs-idp] => 
[module.enable] => Array
    (
        [exampleauth] => 
        [core] => 1
        [admin] => 1
        [saml] => 1
    )

[session.duration] => 28800
[session.datastore.timeout] => 14400
[session.state.timeout] => 3600
[session.cookie.name] => SimpleSAMLSessionID
[session.cookie.lifetime] => 1800
[session.cookie.path] => .sso.test
[session.cookie.domain] => .sso.test
[session.cookie.secure] => 1
[session.phpsession.cookiename] => SimpleSAML
[session.phpsession.savepath] => /
[session.phpsession.httponly] => 
[session.authtoken.cookiename] => SimpleSAMLAuthToken
[session.rememberme.enable] => 
[session.rememberme.checked] => 
[session.rememberme.lifetime] => 1209600
[memcache_store.servers] => Array
    (
        [0] => Array
            (
                [0] => Array
                    (
                        [hostname] => localhost
                    )

            )

    )

[memcache_store.prefix] => 
[memcache_store.expires] => 129600

[theme.use] => default
[template.auto_reload] => 
[production] => 1
[assets] => Array
    (
        [caching] => Array
            (
                [max_age] => 86400
                [etag] => 
            )

    )

[idpdisco.enableremember] => 1
[idpdisco.rememberchecked] => 1
[idpdisco.validate] => 1
[idpdisco.extDiscoveryStorage] => 
[idpdisco.layout] => dropdown
[authproc.idp] => Array
    (
        [30] => core:LanguageAdaptor
        [45] => Array
            (
                [class] => core:StatisticsWithAttribute
                [attributename] => realm
                [type] => saml20-idp-SSO
            )

        [50] => core:AttributeLimit
        [99] => core:LanguageAdaptor
    )

[authproc.sp] => Array
    (
        [90] => core:LanguageAdaptor
    )

[metadatadir] => metadata
[metadata.sources] => Array
    (
        [0] => Array
            (
                [type] => flatfile
            )

    )

[metadata.sign.enable] => 
[metadata.sign.privatekey] => 
[metadata.sign.privatekey_pass] => 
[metadata.sign.certificate] => 
[metadata.sign.algorithm] => http://www.w3.org/2001/04/xmldsig-more#rsa-sha256
[store.type] => phpsession
[store.sql.dsn] => sqlite:/path/to/sqlitedatabase.sq3
[store.sql.username] => 
[store.sql.password] => 
[store.sql.prefix] => SimpleSAMLphp
[store.sql.options] => Array
    (
    )

[store.redis.host] => localhost
[store.redis.port] => 6379
[store.redis.username] => 
[store.redis.password] => 
[store.redis.prefix] => SimpleSAMLphp
[store.redis.mastergroup] => mymaster
[store.redis.sentinels] => Array
    (
    )

[proxymode.passAuthnContextClassRef] => 

)

Help for this I am stuck in redirect loop

PHP file_get_contents() doesn’t get the content of the correct file

I need to get the content of some files in order to upload them in a second moment.
The files are placed in one of the project folders (project_name_root/docs/).

I retrieve the file content dynamically and the problem is that that content is always the same. What is read is always the first file content and not all the other ones, even tough the filename getting saved is actually correct.

Basically I have and index.php where I create the instance, then I get the file names and then I call the insert_doc function for each of them. So, what could be the problem? Thanks!

index.php

require_once('DOCAREAProto.class.php');
$instance = new DOCAREAProto("AGSPRWS","AGSPRWS");

$files = "SELECT...";

foreach($files as $file) {
    $DOCUMENTS = [
            "P" => [
                  "name" => $file['name'].".pdf",
                  "path" => "docs/",
                  ]
             ];     

    $instance->insert_doc($DOCUMENTS);
}

DOCAREAProto.class.php

class DOCAREAProto{
   private $DOCUMENTS = [];

function insert_doc($documents){
        $this->DOCUMENTS = $documents;
        $name = $this->DOCUMENTS["P"]['name'];
        $path = $this->DOCUMENTS['P']['path'];
        $file = $path.$name;

        $doc = file_get_contents($file);

        ...

}

Replacing space after number with hard space in p tag

I would like to replace a space after a number with hard-space ” ” only in p tags.

I wrote this code:

   $pattern = "/<p>[0-9] </p>/";
   return preg_replace($pattern, "$1&nbsp;", $text);

But it does nothing, why? Can you please help?

Example:

Input : "My 90 days work."
Output: "My 90&nbsp;days work."

Thank you a lot.

How to autoload phar files(httpful.phar) in custom component in Joomla 4.3 (php psr4 or psr0 based autoloading)?

I am using a custom component in Joomla and using httpful.phar (https://github.com/nategood/httpful) for REST API. Instead of using the include or require statement, I want to autoload its namespaces and classes. httpful source has Bootstrap.php which does the autoloading. But how can I autoload all the classes and namespaces in similar fashion as other component’s classes and namespaces are autoloaded? I am a little clueless here as this is a phar archive and I can’t directly access its files.

I tried searching over internet and forums but did not get any similar results.

Differences in double subtract date modifiers between PHP <8.2 and 8.2+

I am upgrading a codebase from PHP 7.4 to 8.2. My unit tests picked up an oddity in an area of code that modifies a provided date.

It looks like PHP 8.2 introduced some behaviour with how date functions work when you modify a date using “–” (double arithmetic operators).

public static function getCorrectedTime(
        int $year,
        int $month,
        int $day,
        int $index,
        string $period
    ): int {

        // PHP 7.4 - if $index=0, $timestamp=1625443200, if $index=-1, $timestamp=1625529600 - test passes
        // PHP 8.2 - if $index=0, $timestamp=1625443200, if $index=-1, $timestamp=1625356800 - test fails
        $timestamp = strtotime("{$year}-{$month}-{$day} -{$index} {$period}");
        return $timestamp;
    }

This seems to be the case when using DateTime objects and it’s ->modify() method. It seems like it’s more to do with the double “-” modifier that will be used if $index is a negative number. See scratch pad here: https://3v4l.org/fNR2X

But this method needs to support both positive and negative modifiers being sent to it.

Before I completely refactor this old code, I was trying to hunt down an actual description of the change to PHP 8.2 so I can understand exactly what was changed. I can see nothing about this in the changelog or Google hunt. Is anyone aware?

JOIN queries in DataTable using AJAX throwing Unknown column error

I’m trying to attach products count to the existing categories datatable. Below is the php code for fetching data using ajax.

I tried name LIKE :name OR description LIKE :description and I’m getting error as below.

Fatal error: Uncaught PDOException: SQLSTATE[23000]: Integrity constraint violation: 1052 Column ‘name’ in where clause is ambiguous

Then I tried by adding table name as prefix for each field, like
cat.name LIKE :name OR cat.description LIKE :description

This in turn is throwing the error as below.

Fatal error: Uncaught PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘cat.name’ in ‘where clause’

This is happening only while searching. Listing and sorting by field are working without any issue.

The below query in phpmyadmin works without any issue but I don’t know, am I missing any quote or something??

SELECT cat.*, 
       COUNT(prod.cat_id) AS prod_count
FROM categories cat 
JOIN products prod ON cat.id = prod.cat_id
WHERE cat.name LIKE 'f%' OR cat.description LIKE 'f%'
GROUP BY cat.id, cat.name;

Attaching the whole php code below.

<?php 

    $draw = $_POST['draw'];
    $row = $_POST['start'];
    $rowperpage = $_POST['length']; // Rows display per page
    $columnIndex = $_POST['order'][0]['column']; // Column index
    $columnName = $_POST['columns'][$columnIndex]['data']; // Column name
    $columnSortOrder = $_POST['order'][0]['dir']; // asc or desc
    $searchValue = $_POST['search']['value']; // Search value

    $searchArray = array();

    $searchQuery = " ";
    if($searchValue != ''){
        $searchQuery = " AND (name LIKE :name OR 
        description LIKE :description
            ) ";
        $searchArray = array( 
            'name'=>"%$searchValue%",
            'description'=>"%$searchValue%",
            'status'=>"%$searchValue%"            
        );
    }
    
    $conn = $pdo->open();

    $stmt = $conn->prepare("SELECT COUNT(*) AS allcount FROM categories");
    $stmt->execute();
    $records = $stmt->fetch();
    $totalRecords = $records['allcount'];

    $stmt = $conn->prepare("SELECT COUNT(*) AS allcount FROM categories WHERE 1 ".$searchQuery);
    $stmt->execute($searchArray);
    $records = $stmt->fetch();
    $totalRecordwithFilter = $records['allcount'];

    $stmt = $conn->prepare("SELECT cat.*, COUNT(prod.cat_id) AS prod_count
    FROM categories cat LEFT JOIN products prod ON cat.id = prod.cat_id
    WHERE 1 ".$searchQuery."
    GROUP BY cat.id, cat.name ORDER BY ".$columnName." ".$columnSortOrder." LIMIT :limit,:offset");

    foreach ($searchArray as $key=>$search) {
        $stmt->bindValue(':'.$key, $search,PDO::PARAM_STR);
    }

    $stmt->bindValue(':limit', (int)$row, PDO::PARAM_INT);
    $stmt->bindValue(':offset', (int)$rowperpage, PDO::PARAM_INT);
    $stmt->execute();
    $item_records = $stmt->fetchAll();

    $data = array();

    foreach ($item_records as $row) {

        $data[] = array(
            "id"=>$row['id'],
            "name"=>$row['name'],
            "description"=>$row['description'],
            "prod_count"=>$row['prod_count'],
            "status"=>$row['status']
        );
     }    
    
    $pdo->close();

    $response = array(
        "draw" => intval($draw),
        "iTotalRecords" => $totalRecords,
        "iTotalDisplayRecords" =>  $totalRecordwithFilter,  
        "data" => $data
    );

    echo json_encode($response);
?>

Working with Laravel and Yajra DataTables: how can I enable inline editing using PHP and Ajax?

How to do inline editing with Yajra DataTables in Laravel?

I am trying to implement inline editing using Yajra DataTables in Laravel but I am having some trouble. I have already set up my DataTable and it is displaying my data correctly.

However, I now want to be able to edit the fields inline and save the changes to my database. I have researched on online resources and documentations but I could not seem to figure out how to do it.

If you have any experience with Yajra DataTables and inline editing in Laravel, It would be greatly appreciated if you could share some code or resources that can help me implement this feature. Thank you in advance for your help!

CustomerController.php

public function list(Request $request)
{
    $customers = Customer::orderBy('id', 'desc')->get();

    return DataTables::of($customers)
        ->addIndexColumn()
        ->addColumn('created_at', function ($customer) {
            return $customer->created_at->format('d.m.Y H:i:s');
        })
        ->addColumn('name', function ($customer) {
            return $customer->name;
        })
        ->addColumn('phone', function ($customer) {
            return $customer->phone;
        })
        ->addColumn('status', function ($customer) {
            return $customer->status?->title;
        })
        ->addColumn('treatment', function ($customer) {
            return $customer->treatment?->title;
        })
        ->addColumn('action', function ($row) {
            $btn = '<a href="' . route('customer.edit', $row) . '" class="btn btn-primary btn-sm">Düzenle</a>';
            $btn .= '<form action="' . route('customer.destroy', $row) . '" method="post" class="d-inline-block">
                ' . csrf_field() . '
                ' . method_field('DELETE') . '
                <button class="btn btn-danger btn-sm" type="submit" onclick="return confirm('Silmek istediğinize emin misiniz?')">Sil</button>
            </form>';
            return $btn;
        })
        ->rawColumns(['action', 'name'])
        ->make(true);
}

customer/index.blade.php

@extends('layouts.app')
@section('title', 'Müşteriler')
@section('css')
    <link href="{{ asset('assets/lib/select2/css/select2.min.css') }}" rel="stylesheet">
    <link href="//cdn.datatables.net/1.13.4/css/jquery.dataTables.min.css" rel="stylesheet">
@endsection
@section('content')
    <div class="slim-mainpanel">
        <div class="container">

            @if(session('success'))
                <div class="alert alert-solid alert-success mg-t-25" role="alert">
                    {{ session('success') }}
                </div>
            @endif

            <div class="section-wrapper mg-t-20">
                <div class="report-summary-header">
                    <div>
                        <h4 class="tx-inverse mg-b-3">Müşteriler</h4>
                        <p class="mg-b-0">Müşterilerin listelendiği sayfadır.</p>
                    </div>
                    <div>
                        <a href="{{ route('customer.create') }}" class="btn btn-primary"><i
                                class="icon ion-ios-plus-outline tx-24"></i> Yeni Ekle</a>
                    </div>
                </div><!-- d-flex -->

                <div class="table-responsive">
                    <table class="table table-bordered table-colored" id="customers">
                        <thead>
                        <tr>
                            <th class="wd-5p">#</th>
                            <th>Kayıt Tarihi</th>
                            <th>Adı</th>
                            <th>Telefon</th>
                            <th>Durum</th>
                            <th>Tedavi</th>
                            <th>İşlem</th>
                        </tr>
                        </thead>
                        <tbody>
                        </tbody>
                    </table>
                    <br>
                </div><!-- table-wrapper -->
            </div><!-- section-wrapper -->

        </div><!-- container -->
    </div><!-- slim-mainpanel -->
@endsection
@section('js')
    <script src="//cdn.datatables.net/1.13.4/js/jquery.dataTables.min.js"></script>
    <script src="{{ asset('assets/lib/moment/js/moment.js') }}"></script>
    <script src="{{ asset('assets/lib/select2/js/select2.min.js') }}"></script>
    <script src="{{ asset('assets/lib/jquery-ui/js/jquery-ui.js') }}"></script>
    <script src="{{ asset('assets/js/app.js') }}"></script>
    <script>
        $('#customers').DataTable({
            processing: true,
            serverSide: true,
            ajax: "{{ route('customer.list') }}",
            columns: [
                {data: 'DT_RowIndex'},
                {data: 'created_at'},
                {data: 'name'},
                {data: 'phone'},
                {data: 'status'},
                {data: 'treatment'},
                {
                    data: 'action',
                    name: 'action',
                    orderable: true,
                    searchable: true
                },
            ],
            search: {
                return: true,
            },
            language: {
                "url": "//cdn.datatables.net/plug-ins/1.13.4/i18n/tr.json"
            },
        });
    </script>
@endsection

I can’t just sign up and comment on a post? [closed]

I have one question about my php form:

if (!isset($_REQUEST['email_address'])) {
    header( "Location: $home_page" );

what does this do?
Does it do anything because it came with the source code I found to make my own:

<form method="post" action="send_mail.php">
<label><h4>Name</h4>
<input type="text" name="name" placeholder="Name not required..." maxlength="40">
</label>
<br>
<font size="3">
<label><h4>Comment</h4>
<textarea name="comment" minlength="10" maxlength="650" placeholder="Type your comment here.... " required oninvalid="this.setCustomValidity('Please type a comment with at least 10 characters.')" oninput="setCustomValidity('')"></textarea>
</label>
<br>
<button type="submit">Submit Comment</button>
<br>
</form>
<?php
$webmaster_email = "[email protected]";
$thankyou_page = "thank_you.html";
$error_page = "technical_error.html";
$home_page = "index.htm";
$name = $_REQUEST['name'] ;
$minlen = 10;
$comment = $_REQUEST['comment'] ;
if (empty($name)) { $name='Anonymous';  }
$msg = "rnName: " . $name . "rnrnComment: " . $comment . "rn";

if (!isset($_REQUEST['email_address'])) {
    header( "Location: $home_page" );
}

if(strlen(trim($_POST['comment'])) < $minlen) { 
    header( "Location: $error_page" );
}
    
elseif($_SERVER['REQUEST_METHOD'] === 'POST'){
    mail( "$webmaster_email", "Comment on Antarctica-UFO.com", $msg );
    header( "Location: $thankyou_page" );
}
?>

I am sorry, I did not try much but I don’t know what to do.

Achieving real-time notification of database updates in PHP without polling

I have a php script which will update a database when a user enters some text into the site. I want to also send an update so that a different online user will be notified about this. If possible it’d be nice to use only core php. I don’t really want to use a polling-like method. What other ways are there to achieve this?

Would semaphores or shared memory be an option? If so then how would that work? Or is using websockets a better choice for my use case?

How can i enable indvidual column search in Yajra datatable v10?

I’m using yajra datatables v10 with laravel v9. I’m facing some issues as i want to enable seperate search on each column. This thing is done the search is only works for id, email, total paid columns but search is not working for car, payment status, booking status, pickup date columns.
I have tried many solution i can get from gpt, bard.
Please review my code and help me to get the solution.

 public function dataTable(QueryBuilder $query,Request $request): EloquentDataTable
{
    return (new EloquentDataTable($query))
        ->addColumn('email',fn($query) => $query->email)
        ->addColumn('total paid',fn($query) => $query->total_paid)
        ->addColumn('car',fn($query) => $query->makeTitle .' '. $query->makeModelTitle)
        ->addColumn('payment status',fn($query) => $query->payment_status == 1 ? 'Paid' : 'Unpaid')
        ->addColumn('pickup date', fn ($query) => $query->pickup_date)
        ->addColumn('booking status',function($query) {
            $status = $query->booking_status;
            $bgColor = 'bg-warning';
            if($status == 'cancelled') $bgColor = 'bg-danger';
            elseif($status == 'confirmed') $bgColor = 'bg-success';

            return "<span class='badge $bgColor'>$status</span>";
        })
        ->addColumn('actions',function($query) {
            $status = $query->booking_status;
            $returnValue = '<div class="d-flex justify-between">';
            if($status == 'pending'){
                $confirmRoute = route('bookings.confirm', $query->id);
                $cancelRoute = route('bookings.cancel', $query->id);
                $token = csrf_token();
                $confirmForm = '<form action="'.$confirmRoute.'" method="POST">
                                    <input type="hidden" name="_token" value="'.$token.'">
                                    <button type="submit" class="btn btn-sm btn-icon btn-success" title="approve">
                                    <i class="fa fa-check-circle"></i>
                                    </button>
                                </form>';

                $cancelForm = '<form action="'.$cancelRoute.'" method="POST">
                                    <input type="hidden" name="_token" value="'.$token.'">
                                    <button type="submit" class="btn btn-sm btn-icon btn-danger" title="reject">
                                    <i class="fa fa-times-circle"></i>
                                    </button>
                                </form>';

                $returnValue .= $confirmForm . $cancelForm ;
            }

            $showRoute = route('bookings.show', $query->id);
            $showButton = '<div class="d-inline-block text-nowrap">
                                <button class="btn btn-sm btn-icon show-record">
                                    <a href="'.$showRoute.'">
                                        <i class="fa fa-eye"></i>
                                    </a>
                                </button>';

            $returnValue .= $showButton ;
            if(auth()->user()->hasRole('admin')){
                $editRoute = route('bookings.edit', $query->id);
                $editButton = '<button class="btn btn-sm btn-icon edit-record"><a href="'.$editRoute.'"><i
                        class="fa fa-edit"></i></a></button>';

                $returnValue .= $editButton ;
            }

            return $returnValue.'</div>';
        })
        ->rawColumns(['booking status','actions'])

        // order
        ->orderColumn('email', function ($query, $order) {
            $query->orderBy('email', $order);
        })
        ->orderColumn('total paid', function ($query, $order) {
            $query->orderBy('total_paid', $order);
        })
        ->orderColumn('car', function ($query, $order) {
            $query->orderBy('makeTitle', $order);
        })
        ->orderColumn('payment status', function ($query, $order) {
            $query->orderBy('payment_status', $order);
        })
        ->orderColumn('booking status', function ($query, $order) {
            $query->orderBy('booking_status', $order);
        })
      // search
      ->filter(function ($query) use ($request) {
        $searchValue = $request->search['value'] ?? false;
        $startDate = $request->start_date ?? false;
        $endDate = $request->end_date ?? false;
        $query->where(fn ($query) =>
        $query->when($searchValue, fn ($query) =>
        $query->where('email', 'like', "%$searchValue%")
          ->orWhere('booking_status', 'like', "%$searchValue%")
          ->orWhere('total_paid', 'like', "%$searchValue%")
          ->orWhere('booking_status', 'like', "%$searchValue%")
          ->orWhereHas('car.make', fn ($query) =>
          $query->where('title', 'like', "%$searchValue%")
          )
          ->orWhereHas('car.makeModel', fn ($query) =>
          $query->where('title', 'like', "%$searchValue%")
          )
        )
          ->when($startDate && $endDate, fn($query) => $query->whereBetween('bookings.pickup_date', [$startDate, $endDate])
          ));
      })
        ->setRowId('id');
}
public function query(Booking $model): QueryBuilder
{
    // return $model->newQuery();

    $selectColumns = [
        'bookings.id',
        'bookings.email',
        'bookings.total_paid',
        'bookings.payment_status',
        'bookings.booking_status',
        'bookings.pickup_date',


        'makes.title as makeTitle',
        'make_models.title as makeModelTitle',
    ];

    $query = $model->select($selectColumns)->join('cars','cars.id','=','bookings.car_id')
                                ->join('makes','makes.id','=','cars.make_id')
                                ->join('make_models','make_models.id','=','cars.make_model_id')
                                ->where('bookings.payment_status', '<>', 0);

    if(auth()->user()->hasRole('shop')){
        $shopCarsIds = auth()->user()->shop->cars->pluck('id');
        $query->whereIn('car_id',$shopCarsIds);
    } elseif (auth()->user()->hasRole('partner')){
        $partner_id = auth()->user()->partner_id;
        $query->where('partner_id',$partner_id);
    }

    return $query;
}
public function html(): HtmlBuilder
{
    return $this->builder()
        ->setTableId('bookings-table')
        ->columns($this->getColumns())
        ->minifiedAjax()
        ->ajax([
          'url' => route('bookings.index'),
          'type' => 'GET',
          'data' => 'function(d) {d.start_date = start_date, d.end_date = end_date}'
        ])
        ->dom('Bflrtip')
        ->orderBy(0,'asc')
        ->parameters([
          "pageLength" => "10",
          'initComplete' => 'function () {
              var table = this.api();
              var searchRow = $("<tr/>").appendTo($(table.table().header()));

              table.columns().every(function () {
                  var column = this;
                  var searchCell = $("<th/>").appendTo(searchRow);
                  var headerText = column.header().innerText;
                  if (headerText.includes("ACTIONS")) {
                      // Exclude action button column
                      return;
                  }


                  var input = document.createElement("input");
                  var placeholder = "";
                  var dataColumn = "";

                  // Set attributes based on column name
                  switch (column.header().innerText) {
                      case "ID":
                          placeholder = "Search ID";
                          dataColumn = "id";
                          break;
                      case "EMAIL":
                          placeholder = "Search Email";
                          dataColumn = "email";
                          break;
                          case "TOTAL PAID":
                          placeholder = "Search Paid";
                          dataColumn = "paid";
                          break;
                      case "CAR":
                          placeholder = "Search Car";
                          dataColumn = "car";
                          break;
                      case "PICKUP DATE":
                          placeholder = "Search Pickup date";
                          dataColumn = "pickup date";
                          break;
                      case "PAYMENT STATUS":
                          placeholder = "Search Payment Status";
                          dataColumn = "payment status";
                          break;
                      case "BOOKING STATUS":
                          placeholder = "Search Booking Status";
                          dataColumn = "booking status";
                          break;
                  }

                  $(input).appendTo(searchCell)
                      .attr("type", "text")
                      .addClass("form-control dt-input")
                      .attr("placeholder", placeholder)
                      .attr("data-column", dataColumn)
                      .attr("data-column-index", column.index())
                      .on("keyup change clear", function () {
                          var searchValue = $(this).val();
                          var searchRegex = column.search() instanceof RegExp ?
                              searchValue :
                              $.fn.dataTable.util.escapeRegex(searchValue);
                          column.search(searchRegex, false, false, true).draw();
                      });
              });
        }'
        ]);
}
 public function getColumns(): array
{
    return [
        Column::make('id'),
        Column::make('email',true),
        Column::make('total paid', true),
        Column::make('car', true),
        Column::make('pickup date', true),
        Column::make('payment status', true),
        Column::make('booking status', true),
        Column::make('actions'),
    ];
}

Fatal error: Uncaught Error: Class “IlluminateSupportFacadesRateLimiter

I checked the other posts on Stack Overflow, but none of them resolved my issue.

I’m also still learning Laravel, so 100% beginner.

I follow the steps from this article to install it ( composer create-project –prefer-dist laravel/laravel blog
) and wanted to test out the RateLimiter.

But I keep getting the ‘Fatal error: Uncaught Error: Class “IlluminateSupportFacadesRateLimiter” not found’ error.

I made sure that ‘RateLimiter’ => IlluminateSupportFacadesRateLimiter::class’ is in the config/app.php ( it wasn’t there before, but it makes no difference ).

This is the code that I’m testing, which comes from the official documentation.

use IlluminateSupportFacadesRateLimiter;

$executed = RateLimiter::attempt(
    'send-message:',
    $perMinute = 5,
    function() {
        echo 'hi';
        // Send message...
    }
);

if (! $executed) {
    return 'Too many messages sent!';
}

I also tried to run composer update again to make sure everything was up to date, and checked if I could maybe download the RateLimiter package here, but I don’t see it.

I do suspect the package is missing, but no idea how to fix, and all suggestions from other posts on Stack Overflow make no difference to me.

Any suggestions what I could check / do to fix this error?

PHP comparing number get error it just simple comparasion

i write code like this:

$a = 1.84;
$b = 1.84;

if($a==$b) echo "na equal bn";
else if($a<$b) echo "na less than bn";
else if($a>$b) echo "na greater than bn";

i’m so confused why the result like this:

enter image description here

while i compile in other php like online php, the result is correct “a equal b”. is there any problem with my php? PHP 7.4.33

Composer installation proxy settings error

I was trying to install composer but I got this error :
The Composer installer script was not successful [exit code 1].

Your proxy settings may be causing this error.

Script Output:
The “https://getcomposer.org/versions” file could not be downloaded: Failed to open stream: No connection could be made because the target machine actively refused it

I tried to change the proxy ip but it doesn’t work

Redirection problem from userform.php to statusreport.php upon login

Whenever I log in with a username and password from the database I created my form.php isn’t redirecting to my statusreport.php.

This is my form.php

  <?php
    session_start();

    include('includes/header.php');
    include('includes/common.php');

    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
      // Form submitted, attempt login
      $username = $_POST['username'];
      $password = $_POST['userpassword'];

      // Connect to the database
      $conn = getDatabaseConnection();

      // Prepare the query to fetch user credentials
      $query = "SELECT * FROM users WHERE UserName = :username";
      $stmt = $conn->prepare($query);
  $stmt->bindValue(':username', $username);
  $stmt->execute();
  $user = $stmt->fetch(PDO::FETCH_ASSOC);

  if ($user && password_verify($password, $user['UserPassword'])) {
    // Successful login, set session variables
    $_SESSION['UserID'] = $user['ID'];
    $_SESSION['UserName'] = $user['UserName'];
    $_SESSION['FirstName'] = $user['FirstName'];
    $_SESSION['LastName'] = $user['LastName'];
    $_SESSION['UserLevel'] = $user['UserLevel'];

    // Redirect to statusreport.php
    header('Location: statusreport.php');
    exit;
  } else {
    // Failed login
    $loginError = true;
    echo "<div class="error">Invalid username or password</div>";
  }
}
?>

<h2>Login Form</h2>
<section>
  <?php if (isset($loginError) && $loginError): ?>
    <div class="error">Invalid username or password</div>
  <?php endif; ?>
  <form action="userform.php" method="POST">
    <label for="u`your text`sername">Username:</label>
    <input type="text" name="username" id="username" required><br>

    <label for="userpassword">Password:</label>
    <input type="password" name="userpassword" id="userpassword" required><br>

    <input type="submit" value="Submit">
  </form>
</section>

<?php
include('includes/footer.php');
?>

I have tried making sure the database correction is correct as well as the the table and column variables match what I have inputted in my php code file. Whenever I enter the correct UserName and UserPassword from the table in phpmyadmin and hit submit it redirects me to a blank form.php page and not the statusreport.php?