How to retrieve records by as a range (As1-As10) in laravel?

is there any possibility to retrieve records as a range.For an example there is a table with column as ref_numbers.Sample values for the ref_numbers are A1,A2,A3,A4….AB1,AB2,AB3,AB4…
I want to retrieve the records of specific range starting value and end value.Such as in this case (A1-A2,AB1-AB4)
How can i achieve this ,Using eloquent or query builder or Raw queries in laravel?

Fatal error: Uncaught mysqli_sql_exception: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server [closed]

Fatal error: Uncaught mysqli_sql_exception: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘@gmail.com’ at line 1 in C:xampphtdocsbookyourpropertyprofile.php:34 Stack trace: #0 C:xampphtdocsbookyourpropertyprofile.php(34): mysqli_query(Object(mysqli), ‘SELECT * FROM u…’) #1 {main} thrown in C:xampphtdocsbookyourpropertyprofile.php on line 34

<?php
    
    $fetch_user_details_query = "SELECT * FROM user_master WHERE user_email_address = ".$_SESSION['username'];
    $fetch_user_details_q = mysqli_query($conn, $fetch_user_details_query);
    $fetch_user_details_row = mysqli_fetch_array($fetch_user_details_q);
?>

Running a project on vagrant

After reinstalling Vagrant, I had a problem with starting projects, the vagrant up and vagrant reload –provision command launch the VM perfectly and it works, but when trying to open projects in the browser, they just don’t open, can someone tell me what the problem is?

Homestead.yml file

---
ip: "192.168.56.56"
memory: 2048
cpus: 2
provider: virtualbox

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

folders:
    - map: ~/code
      to: /home/vagrant/projects

sites:
    - map: parser.ru
      to: /home/vagrant/projects/parser/public

databases:
    - homestead

features:
    - mysql: true
    - mariadb: false
    - postgresql: false
    - ohmyzsh: false
    - webdriver: false

services:
    - enabled:
          - "mysql"
#    - disabled:
#        - "postgresql@11-main"

#ports:
#    - send: 33060 # MySQL/MariaDB
#      to: 3306
#    - send: 4040
#      to: 4040
#    - send: 54320 # PostgreSQL
#      to: 5432
#    - send: 8025 # Mailhog
#      to: 8025
#    - send: 9600
#      to: 9600
#    - send: 27017
#      to: 27017

hosts file

192.168.56.56   apple-store.ru
192.168.56.56  apple-store-laravel.ru
192.168.56.56  moguta.ru
192.168.56.56  parser.ru
127.0.1.1   pavel

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

Vagrant file

# -*- mode: ruby -*-
# vi: set ft=ruby :

require 'json'
require 'yaml'

VAGRANTFILE_API_VERSION ||= "2"
confDir = $confDir ||= File.expand_path(File.dirname(__FILE__))

homesteadYamlPath = confDir + "/Homestead.yaml"
homesteadJsonPath = confDir + "/Homestead.json"
afterScriptPath = confDir + "/after.sh"
customizationScriptPath = confDir + "/user-customizations.sh"
aliasesPath = confDir + "/aliases"

require File.expand_path(File.dirname(__FILE__) + '/scripts/homestead.rb')

Vagrant.require_version '>= 2.2.4'

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
    if File.exist? aliasesPath then
        config.vm.provision "file", source: aliasesPath, destination: "/tmp/bash_aliases"
        config.vm.provision "handle_aliases", type: "shell" do |s|
            s.inline = "awk '{ sub("r$", ""); print }' /tmp/bash_aliases > /home/vagrant/.bash_aliases && chown vagrant:vagrant /home/vagrant/.bash_aliases"
        end
    end

    if File.exist? homesteadYamlPath then
        settings = YAML::load(File.read(homesteadYamlPath))
    elsif File.exist? homesteadJsonPath then
        settings = JSON::parse(File.read(homesteadJsonPath))
    else
        abort "Homestead settings file not found in #{confDir}"
    end

    Homestead.configure(config, settings)

    if File.exist? afterScriptPath then
        config.vm.provision "Run after.sh", type: "shell", path: afterScriptPath, privileged: false, keep_color: true
    end

    if File.exist? customizationScriptPath then
        config.vm.provision "Run customize script", type: "shell", path: customizationScriptPath, privileged: false, keep_color: true
    end

    if Vagrant.has_plugin?('vagrant-hostsupdater')
        config.hostsupdater.remove_on_suspend = false
        config.hostsupdater.aliases = settings['sites'].map { |site| site['map'] }
    elsif Vagrant.has_plugin?('vagrant-hostmanager')
        config.hostmanager.enabled = true
        config.hostmanager.manage_host = true
        config.hostmanager.aliases = settings['sites'].map { |site| site['map'] }
    elsif Vagrant.has_plugin?('vagrant-goodhosts')
        config.goodhosts.aliases = settings['sites'].map { |site| site['map'] }
    end

    if Vagrant.has_plugin?('vagrant-notify-forwarder')
        config.notify_forwarder.enable = true
    end
end

$_SERVER[‘QUERY_STRING’] not working in CodeIgniter

In my application url after ? i cant able to access the full URL
Example : www.examle.com/test.php?id=3
Normally we can get value like

$_GET['id'] = 3;

But in my app its not working

So i print the $_SERVER values. My output is

[UNIQUE_ID] => YjrrveqpEeuu1FcU9vhhAAAAAAQ
    [HTTP_X_FORWARDED_FOR] => 122.179.51.122, 64.252.100.210
    [HTTP_X_FORWARDED_PROTO] => https
    [HTTP_X_FORWARDED_PORT] => 443
    [HTTP_HOST] => www.example.com
    [HTTP_X_AMZN_TRACE_ID] => Root=1-623aebbd-28269a532256d99658b3dceb
    [HTTP_USER_AGENT] => Amazon CloudFront
    [HTTP_X_AMZ_CF_ID] => vQJWRlfiiA4QWME7ScshqZmO4aR1nPvGjUKluZOfRK478BtFcIJ30w==
    [HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
    [HTTP_VIA] => 2.0 3d029316ef030de84eb214747e947124.cloudfront.net (CloudFront)
    [HTTP_ACCEPT_ENCODING] => gzip, deflate, br
    [HTTP_UPGRADE_INSECURE_REQUESTS] => 1
    [HTTP_SEC_FETCH_SITE] => none
    [HTTP_SEC_FETCH_MODE] => navigate
    [HTTP_SEC_FETCH_USER] => ?1
    [HTTP_SEC_FETCH_DEST] => document
    [HTTP_SEC_CH_UA] => " Not A;Brand";v="99", "Chromium";v="99", "Google Chrome";v="99"
    [HTTP_SEC_CH_UA_MOBILE] => ?0
    [HTTP_SEC_CH_UA_PLATFORM] => "Windows"
    [PATH] => /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
    [SERVER_SIGNATURE] => 
    [SERVER_SOFTWARE] => Apache
    [SERVER_NAME] => www.example.com
    [SERVER_ADDR] => 172.31.67.87
    [SERVER_PORT] => 80
    [REMOTE_ADDR] => 172.31.23.129
    [DOCUMENT_ROOT] => /var/www/html
    [REQUEST_SCHEME] => http
    [CONTEXT_PREFIX] => 
    [CONTEXT_DOCUMENT_ROOT] => /var/www/html
    [SERVER_ADMIN] => root@localhost
    [SCRIPT_FILENAME] => /var/www/html/demo.php
    [REMOTE_PORT] => 33234
    [GATEWAY_INTERFACE] => CGI/1.1
    [SERVER_PROTOCOL] => HTTP/1.1
    [REQUEST_METHOD] => GET
    [QUERY_STRING] => 
    [REQUEST_URI] => /demo.php
    [SCRIPT_NAME] => /demo.php
    [PHP_SELF] => /demo.php
    [REQUEST_TIME_FLOAT] => 1648028605.456
    [REQUEST_TIME] => 1648028605

here also [QUERY_STRING] => is empty

but in another demo server

[QUERY_STRING] => id=3

May i know the reason why main server not showing query_string?

Application Version - CI 3
PHP version - 5.6

Also am using AWS centos server

How do I hash password in .net core similar to PHP hash_password algorithm?

I have a database with has password was written in php using

password_hash(string $password, string|int|null $algo, array $options = []): string

I have the following code:

var phpPassword = "$2y$10$426VO8keeegKJAEo0bJsnebgoxQrRXQjqQ3hjHfLNgpNcRVJtSm5S"
                            var mySalt = "$2a$10$rBV2JDeWW3.vKyeQcM8fFO";
                            string myHash = BCrypt.Net.BCrypt.HashPassword(password, mySalt);

For password 1 it is not working ?

stevenmaguire keycloak plugin returns $token variable how to use this token to in yii2 project for single sign on

    index.php() //plugin
`if (!isset($_GET['code']) || !isset($_SESSION['oauth2state'])) {
        // If we don't have an authorization code then get one
        $authUrl = $provider->getAuthorizationUrl();
        $_SESSION['oauth2state'] = $provider->getState();
        header('Location: ' . $authUrl);
        exit;
    
        //Check given state against previously stored one to mitigate CSRF attack
    }
    
    elseif (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['oauth2state'])) {
    
        unset($_SESSION['oauth2state']);
        exit('Invalid state, make sure HTTP sessions are enabled.');
    } 
    
    else {
    
        // Try to get an access token (using the authorization coe grant)
        try {
            $token = $provider->getAccessToken('authorization_code', [
                'code' => $_GET['code']
                    
                    
            ]);
    //        $token = $provider->getAccessToken('refresh_token', ['refresh_token' => $token->getRefreshToken()]);
    //                 echo $token->getRefreshToken();       
    
    //        print_r($token);
    
        } catch (Exception $e) {
    //        echo 'tttttttttttttttttt';
            exit('Failed to get access token: ' . $e->getMessage());
        }
    
        // Optional: Now you have a token you can look up a users profile data
        try {
    
            // We got an access token, let's now get the user's details
            $user = $provider->getResourceOwner($token);
    //        print_r($user);
            // Use these details to create a new profile
    //        printf('Hello %s!', $user->getName());
        } catch (Exception $e) {
            exit('Failed to get resource owner: ' . $e->getMessage());
        }
    
        // Use this to interact with an API on the users behalf
    //   echo $token->getToken();
        
    }`

using this plugins finally i have getting token that stored user information but problem in where i am adding this tokent in my yii2 project for authentication of user and how the plugins skip the login page of our yii2 projects and directly enter in website without showing login page of our project….

http.response.status_code not comming in apm logs for php

I installed APM-agent for PHP in elasticbeanstalk using .ebextension and logs are coming as well but in my other agent for different services I get http.response.status_code field due to which I’m able to generate alerts if there is some 5xx or 4xx in the logs but when I installed APM-agent for PHP I’m not able to see this field, and here’s the step I installed the apm-php agent –

Download the agent source from https://github.com/elastic/apm-agent-php/.

  1. cd src/ext
  2. phpize
  3. CFLAGS=”-std=gnu99″ ./configure –enable-elastic_apm
  4. make clean
  5. make
  6. sudo make install

So, is there any way I can enable this, or do we have another field that gives us the status code in logs? Please help me because I’m stuck for a long time.

Thank you in advance

How to add php repositories to debian kali linux for php files?

I have added

packages.sury.org/php

through the script, I got on deb.sury.org

===========================================

#!/bin/sh
# To add this repository please do:

if [ "$(whoami)" != "root" ]; then
    SUDO=sudo
fi

${SUDO} apt-get update
${SUDO} apt-get -y install apt-transport-https lsb-release ca-certificates curl
${SUDO} curl -sSLo /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg
${SUDO} sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
${SUDO} apt-get update

===========================================

After running the script is gives an error:

Ign:5 https://packages.sury.org/php kali-rolling InRelease

Err:6 https://packages.sury.org/php kali-rolling Release

404  Not Found [IP: 102.129.144.44 443]

and then continues.
I can’t even add the ubuntu repo it gives the same result and I think that one is one is worse.

I also add [trusted=yes] to the php.list file in /etc/apt/sources.list.d/ directory

It gives an even longer error.
Any help is much appreciated

Apache and PHP on Windows: access to a network directory using another user instead “Local System”

I have a Windows Server 2019 running web server Apache 2.4 PHP8 with user “Local System”. This server is not in a Domain and I want to mantain the user “Local System” which executes the services for security reasons.
In a PHP script I want to execute scandir to a network folder “srv-datadocuments” and I want to configure Apache to use another user to access this folder.
Then:

  1. I create the file .htpasswd with username “user.data” and relative password
  2. I add these line into the apache configuration file:
<Directory "\srv-datadocuments">
  AuthType Basic
  AuthName "Access only allowed for user.data"
  AuthUserFile .htpasswd
  Require user user.data
</Directory>
  1. I restart the service.

If I try to execute the PHP script, the web server still returns “access is denied (code 5)”.

The user credentials are stored into the Windows Server 2019 and the destination server and if I try to access with file explorer with “user.data” user it works, then I think it is a bad configuration on apache configuration file
Thank for you help

Best regards

Matteo

I tried to add some double quotes to reference the .htpasswd files, I tried to change something else to the configuration but it still not works.
The web server must continue to be run by the “Local Server” user and the same web server must access to the directory “srv-datadocuments” with the different user “user.data”

Implementation of Yasumi in Laravel 9

There is a posting from 2016 that describes how to implement Yasumi:
https://www.yasumi.dev/
into Laravel. But this looks like it completely outdated now. What is the correct way to implement it into Laravel 9?

Post I am referencing from 2016:
https://stackoverflow.com/a/41266340/8207054

I am using this code (AppServiceProvider):

<?php

namespace AppProviders;

use IlluminateSupportServiceProvider;
use CarbonCarbon;


class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        $this->app->singleton('yasumi', YasumiYasumi::create('USA', Carbon::now()->format('Y')));

    }

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        //

    }
}

but it causes this error: IlluminateContainerContainer::bind(): Argument #2 ($concrete) must be of type Closure|string|null

Updating SQL Select Query to a parametized query inside of PHP Function with parameters [duplicate]

I have been trying update this SQL select query to a parmetized query so it is not vulnerbale to SQL injection. I have tried hundreds of different combinations, I have looked at hundreds of web resources and questions on Stack Overflow but I still cannot get it to work.

function SQLReturnOneCustomerValue($number,$value){

global $host,$username,$password,$database;

$SQL_query = "select " . $value ." from customer where CustomerNumber =". $number . " limit 1";
$DataB_link = new mysqli($host, $user, $pass) or die("Could not connect to host.");
$DataB_link->query("SET NAMES 'utf8'");

$DataB_link->select_db($database) or die ("Could not find or access the database.");
$result = $DataB_link->query($SQL_query) or die ("Wrong Number / error");

$result->data_seek( 0); $output = @$result->fetch_array()[0] or die ("Wrong Number / error");
return $output;
}

I know how to write a parametized query but how do I do it in a PHP function.
Just a point in the right direction is all I need.
Thank you for your time.

PHP from 5.6 to 7.2 advice [duplicate]

Fatal error: Call to undefined function mysqli_result()

Hi,
I am having some issues migrating old code from Php 5.6 to 7.2 (I know, I’m late !).
The initial code was :

$datama=mysql_query("SELECT COUNT(*) as TOTALFOUNDA FROM errorlog WHERE IP ='$ff' and datenow>'$last' and counting='3'"); 
$anymatchesa=mysql_result($datama,0,"TOTALFOUNDA"); 

And I came up with this (the connexion to the DB with $conx is OK) :

$datama=mysqli_query($conx,"SELECT COUNT(*) as TOTALFOUNDA FROM errorlog WHERE IP ='$ff' and datenow>'$last' and counting='3'"); 
$anymatchesa=mysqli_result($datama,0,"TOTALFOUNDA"); 

But I get an error “Fatal error: Call to undefined function mysqli_result()”…

Could you help me out ?
Many Thanks !!!!

PHP: a button that opens a link with the current URL? [duplicate]

I’m looking for a way to place a button onto my website for reporting the current page the User is looking at. I do need the Button to open a new href tab (and there’s what I do not know) and include the URL where the User clicks on the button.

Example:

User clicks on the “Report” Button at https://example.com/image/xr339r5 and a new tab opens as https://example.com/support/index.php?a=add&category=2&url=https://example.com/image/xr339r5

Still learning here – so thank you for your help ❤

I have not found a solutution for this so far.

Calling a GET variable in a POST function

I wanted to add the $item_id into the ‘bid’ table after clicking on the button.
But the $item_id from the $_GET cannot be passed into the $_POST function.
Is it incorrect to call a variable like this?

Thank you in advance for your help!

<?php 
include ('config/dbfunctions.php'); 
include ("helpers/validateBid.php");

$user_id = "";
$item_id = "";
$table= 'bid';
$allBids = selectAll($table);
$items = selectAll('item');

if (isset($_GET['item_id'])) {
    $itemInfoPost  = selectOne('item', ['item_id' => $_GET['item_id']]);
    $item_id = $itemInfoPost['item_id'];
  } 
  

if(isset($_POST['bid-btn'])){
  
        unset($_POST['bid-btn']);
        $_POST['user_id'] = $_SESSION['user_id'];
        $_POST['item_id'] = $item_id;   //$item_id cannot be called
        $bid_id = create($table, $_POST);   
              
        header('location: itemInfo.php?item_id='."$item_id"); 
}