the thumbnails of my web page can’t appear

i use mysql xampp for database and i use that database for save my thumbnails.
this my code for the dashboard buat idk for the error or maybe just require something?
please give tell me

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Dashboard</title>
  <link rel="stylesheet" href="style_dashboard.css">
</head>
<body>
  <!-- Header -->
  <header>
    <h1>Perpustakaan Online</h1>
    <nav>
      <ul>
        <li><a href="./dashboard.php">Home</a></li>
        <li><a href="profile.php">Profile</a></li>
        <li><a href="../logout.php">Logout</a></li>
      </ul>
    </nav>
  </header>

  <!-- Main Content -->
  <main>
    <h2>Dashboard Buku</h2>
    <form method="get">
      <input type="text" name="search" placeholder="Search...">
      <input type="submit" value="Search">
    </form>
    <ul class="book-list">
      <?php
        // Membuat koneksi ke database
        $host = 'localhost';
        $user = 'root';
        $password = '';
        $database = 'library_db';
        $conn = mysqli_connect($host, $user, $password, $database);

        // Memeriksa koneksi
        if (mysqli_connect_errno()) {
          echo "Failed to connect to MySQL: " . mysqli_connect_error();
          exit();
        }

        // Membuat query untuk mengambil data buku
        $query = "SELECT * FROM book";

        // Menambahkan kriteria pencarian jika ada
        if (isset($_GET['search'])) {
          $search = mysqli_real_escape_string($conn, $_GET['search']);
          $query .= " WHERE title LIKE '%$search%' OR author LIKE '%$search%'";
        }

        // Menjalankan query
        $result = mysqli_query($conn, $query);

        // Menampilkan daftar buku
        while ($row = mysqli_fetch_assoc($result)) {
          echo "<li>";
          echo "<img src='" . $row['thumbnail'] . "' alt='" . $row['title'] . "'>";
          echo "<h3>" . $row['title'] . "</h3>";
          echo "<p>Penulis: " . $row['author'] . "</p>";
          echo "</li>";
        }

        // Menutup koneksi
        mysqli_close($conn);
      ?>
    </ul>
  </main>

  <!-- Footer -->
  <footer>
    <p>&copy; 2023 Perpustakaan Online. All rights reserved.</p>
  </footer>
</body>
</html>

enter image description here

i think that from the name of picture(thumbnail) or from the database or the code and maybe from th image format

SQL insert query works on localhost but not on server

The code is for inserting data from an HTML form into a MySQL database. And it works properly on local host. But fails to execute insert query when running on server. The code is given below:

<?php require_once('database/connection.php') ?>
<?php include_once('linker.php') ?>
<a href="index.php" class="btn btn-primary m-auto d-flex justify-content-center text-center">Return to Home</a>
<?php include_once('mail_sending.php') ?>

<div class="container-fluid  mt-5 d-flex justify-content-center">
    <div class="col-md-6 col-12">
        <h2 class="text-capitalize text-center">Add Payment Form</h2>
        <form action="" method="post" enctype="multipart/form-data">
            <div class="row mt-3">
                <div class="card shadow px-5 py-3">
                    <div class="mt-3">
                        <label for="paper_id"><b>Paper ID <span class="text-danger">*</span></b></label>
                        <input type="text" name="paper_id" id="paper_id" class="form-control" placeholder="Please Type Paper ID" required>
                    </div>
                    <div class="mt-3">
                        <label for="paper_title"><b>Paper Title <span class="text-danger">*</span></b></label>
                        <input type="text" name="paper_title" id="paper_title" class="form-control" placeholder="Please Type Paper Title" required>
                    </div>
                    <div class="mt-3">
                    <label for="track"><b>Track <span class="text-danger">*</span></b></label>
                    <!-- <div class="input-group mt-2"> -->
                        <select class="form-select" name="track" id="track" required>
                            <option value="">Please select a track</option>
                            <option value="Science">Science</option>
                            <option value="Business">Business</option>
                            <option value="Law">Law</option>
                        </select>
                    <!-- </div> -->
                </div>
                    <div class="mt-3">
                        <label for="author_name"><b>Author(s) Name: <span class="text-danger">*</span></b></label>
                        <div class="input-group mt-2">
                            <input type="text" class="form-control" name="author_name" id="author_name" placeholder="Please Type Author(s) Name" required>
                        </div>
                    </div>
                    <!-- <div class="mt-3">
                        <label for="author_address"><b>Author(s) Address: <span class="text-danger">*</span></b></label>
                        <input type="text" name="author_address" id="author_address" class="form-control" placeholder="Please Type Author(s) Address" required>
                    </div> -->
                    <div class="mt-3">
                    <label for="author_address"><b>Author(s) Address: <span class="text-danger">*</span></b></label>
                    <textarea class="form-control" name="author_address" id="author_address" cols="30" rows="5" placeholder="Please Type Author(s) Address" required></textarea>
                    </div>
                    <!-- <input type="text" name="author_country" id="author_country" class="form-control" placeholder="Please Type Author(s) Country" required> -->
                    <div class="mt-3">
                        <label for="author_country"><b>Author(s) Country: <span class="text-danger">*</span></b></label>
                    <select class="form-select" id="author_country" name="author_country" required>
    <option>Select a Country</option>
    <?php
    foreach($country_list as $country){
            ?>
    <option value="<?php echo $country['name']; ?>"><?php echo $country['name']; ?></option>
            <?php
    }
    ?>
</select>
</div>
                    <div class="mt-3">
                        <label for="author_category"><b>Author(s) Category <span class="text-danger">*</span></b></label>
                        <select name="author_category" id="author_category" class="form-control">
                            <option value="">Please Select an option</option>
                            <option value="Student(International & SAARC)">Student(International & SAARC) - 30 Dollar</option>
                            <option value="Professional(International & SAARC)">Professional(International & SAARC) - 50 Dollar</option>
                            <option value="Student(International & NON-SAARC)">Student(International & NON-SAARC) - 60 Dollar</option>
                            <option value="Professional(International & NON-SAARC)">Professional(International & NON-SAARC) - 100 Dollar</option>
                            <option value="Student(Local)">Student(Local) - 1000 taka</option>
                            <option value="Professional(Local)">Professional(Local) - 2000 taka </option>
                            <option value="Student(JKKNIU)">Student(JKKNIU) - 500 taka</option>
                        </select>
                    </div>
                    <div class="mt-3">
                        <label for="image"><b>Payment Receive Image <span class="text-danger">*</span></b></label>
                        <input type="file" name="image" id="image" class="form-control" required>
                    </div>
                    <div class="mt-3">
                        <label for="phone"><b>Mobile Number <span class="text-danger">*</span></b></label>
                        <input type="tel" name="phone" id="phone" class="form-control" required>
                    </div>
                    <div class="mt-3">
                        <label for="captcha"><b>Enter Captcha <span class="text-danger">*</span></b></label><br />
                        <input type="text" class="form-control" name="captcha" id="captcha" placeholder="Captcha Code From Below Image" required />
                        <p class="mt-1">
                            <img src="captcha.php?rand=<?php echo rand(); ?>" id="captcha_image" />
                        </p>
                        <p>Can't read the image?
                            <a href='javascript: refreshCaptcha();'>click here</a>
                            to refresh
                        </p>
                    </div>
                    <div class="mt-3">
                        <input type="submit" name="add_payment_form" value="Add" class="btn btn-primary">
                    </div>
                </div>
            </div>
        </form>
        <script>
            function refreshCaptcha() {
                let img = document.images['captcha_image'];
                img.src = img.src.substring(
                    0, img.src.lastIndexOf("?")
                ) + "?rand=" + Math.random() * 1000;
            }
        </script>
    </div>
</div>
<?php
if (isset($_POST['add_payment_form'])) {
     $matched = 0;
     if (isset($_POST['captcha']) && ($_POST['captcha'] != "")) {
         if (strcmp($_SESSION['captcha'], $_POST['captcha']) != 0) {
             $status = "<p class='text-danger text-bold text-center fs-5 mt-3'>
         Entered captcha code does not match! 
         Kindly try again.</p>";
             $matched = 0;
         } else {
             $status = "<p class='text-success text-bold text-center fs-5 mt-3'>Your captcha code is matched.</p>";
             $matched = 1;
         }

         if ($matched === 1) {
            extract($_POST);
            if (isset($_FILES['image']['name'])) {
                $payment_form_image_name = $_FILES['image']['name'];
                $payment_form_image_tmp_name = $_FILES['image']['tmp_name'];
                $path_info = strtolower(pathinfo($payment_form_image_name, PATHINFO_EXTENSION));

                $payment_form_image_name = uniqid() . ".$path_info";
                $manuscript_pdf_file_type = $_FILES['image']['type'];

                $count_error = 0;
                $arr = array("jpg", "png", "jpeg");
                if (!in_array($path_info, $arr)) {
                    $count_error++;
                }

                if ($count_error > 0) {
                    echo "<p class='text-danger text-bold text-center fs-5 mt-3'>Error occurs</p>";
                } else {
                    $sql = "SELECT * FROM new_paper WHERE paper_id='$paper_id'";
                    $result = mysqli_query($conn, $sql);
                    $count = mysqli_num_rows($result);
                    if ($count > 0) {
                        $row = mysqli_fetch_assoc($result);
                        if (isset($row['paper_id']) && $paper_id == $row['paper_id']) {
                            $sql1 = "SELECT * FROM author_information WHERE author_id = $row[author_id]";
                            $result1 = mysqli_query($conn, $sql1);
                            $count1 = mysqli_num_rows($result1);
                            if ($count1 > 0) {
                                $row1 = mysqli_fetch_assoc($result1);
                                // extract($row1);

                                $sql2 = "SELECT * FROM payment_form WHERE paper_id = $paper_id";
                                $result2 = mysqli_query($conn, $sql2);
                                $count2 = mysqli_num_rows($result2);
                                if ($count2 == 0) {

                                    $receiver = $row1['author_email'];
                                    $subject = "Payment Form Submission";
                                    $body = '<p>Your payment form is successfully submitted. You will get confirmation mail when our admin will approve your payment status.</p>';
                                    $send_mail = send_mail($receiver, $subject, $body);

                                    // if (!$send_mail) {
                                    //     echo "<p class='text-danger text-bold text-center fs-5 mt-3'>Email is not sent yet!</p>";
                                    // }

                                    $insert_sql = "INSERT INTO `payment_form`(`paper_id`,`paper_title`,`track`,`author_name`,`author_address`,`author_country`,`author_category`,`phone_number`,`payment_form_image`,`captcha`) VALUES('$paper_id','$paper_title','$track','$author_name','$author_address','$author_country','$author_category','$phone','$payment_form_image_name','$captcha')";
                                    $run_insert_qry = mysqli_query($conn, $insert_sql);
                                    
                                    if ($run_insert_qry) {
                                        move_uploaded_file($payment_form_image_tmp_name, 'Images/payment_form_images/' . $payment_form_image_name);
                                        echo '<script>
                                        alert("A Mail is sent to your email address");
                                        </script>';
                                        echo "<p class='text-success text-bold text-center fs-5 mt-3'>Form is successfully submitted</p>";

                                    } else {

    
                                        echo "<p class='text-danger text-bold text-center fs-5 mt-3'>No data is inserted</p>";
                                        
                                    }
                                } else {
                                    echo "<p class='text-danger text-bold text-center fs-5 mt-3'>Form is already submitted</p>";
                                    
                                }
                            } else {
                                echo "<p class='text-danger text-bold text-center fs-5 mt-3'>Author is not found</p>";
                                
                            }
                        } else {
                            echo "<p class='text-danger text-bold text-center fs-5 mt-3'>Paper ID is not found</p>";
                            
                        }
                    } else {
                        echo "<p class='text-danger text-bold text-center fs-5 mt-3'>Paper is not found</p>";
                    }
                }
            } else {
                echo "<p class='text-danger text-bold text-center fs-5 mt-3'>Image is not found</p>";
            }
        } 
         else {
             echo $status;
         }
        }
    }
?>
<?php include("footer.php") ?>

The code is properly connected with the database and configured properly as the same header files are being used in other parts of the code and those codes are working properly.

I was trying to insert the datas from the form to the database table. It worked properly when I ran it locally using XAMPP but once uploaded to the server shows data not inserted. Specifically the below part of the code:

if ($count2 == 0) {

                                    $receiver = $row1['author_email'];
                                    $subject = "Payment Form Submission";
                                    $body = '<p>Your payment form is successfully submitted. You will get confirmation mail when our admin will approve your payment status.</p>';
                                    $send_mail = send_mail($receiver, $subject, $body);

                                    // if (!$send_mail) {
                                    //     echo "<p class='text-danger text-bold text-center fs-5 mt-3'>Email is not sent yet!</p>";
                                    // }

                                    $insert_sql = "INSERT INTO `payment_form`(`paper_id`,`paper_title`,`track`,`author_name`,`author_address`,`author_country`,`author_category`,`phone_number`,`payment_form_image`,`captcha`) VALUES('$paper_id','$paper_title','$track','$author_name','$author_address','$author_country','$author_category','$phone','$payment_form_image_name','$captcha')";
                                    $run_insert_qry = mysqli_query($conn, $insert_sql);
                                    
                                    if ($run_insert_qry) {
                                        move_uploaded_file($payment_form_image_tmp_name, 'Images/payment_form_images/' . $payment_form_image_name);
                                        echo '<script>
                                        alert("A Mail is sent to your email address");
                                        </script>';
                                        echo "<p class='text-success text-bold text-center fs-5 mt-3'>Form is successfully submitted</p>";

                                    } else {
    // the code shows this message on web server and shows no value for run_insert_query
    echo "<p class='text-danger text-bold text-center fs-5 mt-3'>No data is inserted</p>";
                                        
                                    }
                                } else {
                                    echo "<p class='text-danger text-bold text-center fs-5 mt-3'>Form is already submitted</p>";
                                    
                                }

I have tried to change the order of the code and form. I have tried turning off captcha but so far nothing is working. I need to know why it doesn’t work on webserver and how I can fix it? And is there any difference between how insert queries work on XAMPP vs on a webserver.

Laravel stdout log adding extra keyword in log

I have tried with both inbuilt channels and custom ones as well whenever I am logging something in the terminal/stdout WARN keyword is added before the log.

Laravel log in terminal

but the same logs are coming as they are supposed to be in the log file
Laravel log in file

in my use case I need the logs in json format in the terminal but because of the keyword it is coming as string.

This is logging method(I have tried the same with inbuilt channels like single … but same)


        'methodlog' => [
            'driver' => 'custom',
            'via' => AppLoggingMethodLogChannel::class,
            'formatter' => AppLoggingCustomJsonFormatter::class,
            'name' => 'methodlog',
            'with' => [
                'path' => storage_path('logs/laravel.log'),//'php://stdout',
                'level' => env('LOG_LEVEL', 'debug'),
            ],
        ],        

Edit:
CustomJsonFormatter.php

class CustomJsonFormatter extends JsonFormatter
{
    private $DEFAULT_JSON_FLAGS = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRESERVE_ZERO_FRACTION | JSON_INVALID_UTF8_SUBSTITUTE | JSON_PARTIAL_OUTPUT_ON_ERROR ;
    public function format(LogRecord $record): string
    {
        $formatted = $record['context'];

        if ($this->includeStacktraces) {
            $formatted['stack_trace'] = $record['formatted']['exception'];
        }

        return $this->toJson($formatted, true) . ($this->appendNewline ? "n" : '');
    }
}

MethodLogChannel.php

class MethodLogChannel
{
    public function __invoke(array $config)
    {
        $log = new Logger($config['name']);
        $handler = new StreamHandler($config['with']['path'], $config['with']['level']);
        $handler->setFormatter(new CustomJsonFormatter());
        $log->pushHandler($handler);
        $log->pushProcessor(new IntrospectionProcessor());
        $log->pushProcessor(new WebProcessor($_SERVER));
        return $log;
    }
}

for saving logs

Log::channel(‘methodlog’)->info(”, $log_message);

PHP curl response returns some html page content only

[In this image after the curl_exec($ch4) the values are stored in the $result4 variable when the $result4 printing time its shows some content of the html content only(look at white box) remaining html content are not showing (!!! the remaining content is present but not showing)]

(https://i.stack.imgur.com/Al0Fq.jpg)

Finally how to get full content of html page in the $result4 variable??

Bcoz i needed some values from the html page during the extraction

can you fix my problem about php and mysql?

mysql and my php can’t connect can you fix my problem please i need for test
this is database
this is code php
this is result after run that code (fatal eror)

<?php
require_once "../function.php";
session_start();

$host = "localhost";
$username = "root";
$password = "";
$database = "dbpariwisata"; 

// Koneksi ke database
$koneksi = mysqli_connect($host, $username, $password, $database);
 
// Cek apakah form telah disubmit
if($_SERVER["REQUEST_METHOD"] == "POST") {
    // Mengambil data yang diinputkan pada form login
    $username = $_POST['username'];
    $password = $_POST['password'];
    
    // Query untuk mencari user dengan username dan password yang sesuai
    $query = "SELECT * FROM users WHERE username='$username' AND password='$password'";
    $result = mysqli_query($koneksi, $query);
 
    // Jika data user ditemukan
    if(mysqli_num_rows($result) == 1) {
        // Buat session dan redirect ke halaman home
        $_SESSION['login'] = true;
        header("location: home.php");
    } else {
        // Jika data user tidak ditemukan
        echo "<script>alert('Username atau password salah');</script>";
    }
}
?>

i hope this problem can finished

Open AI Stream Completion Set Variable Inside Function PHP With Openai-php SDK

How to set variable inside this openai-php sdk function in stream completion ?
I am using this open-ai library

https://github.com/orhanerday/open-ai

This is the code :

 $client->completion($configuration, function ($curl_info, $data) { 
            $response = ""; // This Variable Keep Init Because it is looping in this function                                       
            $cleanJson = str_replace("data: ", "", $data);                      
            if ($data != "data: [DONE]nn") {
                $arrayData = json_decode($cleanJson, true);                         
                $response = $response . $arrayData['choices'][0]['text']; // <= I cannot save all the content data to variable $response because it's keep replaced             
            } else {
                echo "ITS DONE";            
            }

            ob_flush();
            flush();            
            return strlen($data);               
         });    

I cannot define variable outside $client->completion function. Because it will not detect inside $client->completion function.

What I want is I can pass the variable outside to $client->completion function.

example :

 $client->completion($configuration, function ($curl_info, $data, $response, $other) { 

});

That example give an error.

How do I pass the $response or $other variable in the $client->Completion ?

how to loop through x times based on each foreach value? PHP

my question is as follows.

I owe x friends y amount of money.

I have Fixed amount of money to payback right now.

I need to pay back each friend evenly.
example: $1 amy then $1 Amdy and so forth till my fixedAmount is used up.

for instance.

$fixedAmount = 10; $arr = array("amy" => 5,"amdy" => 55,"amfy" => 15);

thanks in advance for any help offered.

getting this answered when i have enough Fixed Amount of money to pay back everyone I got it working as below.

$a = array_sum($arr);

if($fixedAmount >= $a) {
 echo 'fully paid';
}

now the problem is what if i dont have enough money to pay back everyone?

honestly dont know which functions or what is best to use to get the result.

Find JSON in a big text [closed]

I’m wondering how you would find JSON part in a text that contain also normal text.
My use case is that I use ChatGPT (via API) to generate JSON but sometimes it “like” to add explainations.

Here is an example :

Here's a sample JSON object for Paris coordinates:
{
  "country": "France",
  "capital": "Paris",
  "lat": 48.8566,
  "lng": 2.3522
}

Explanation:

    "country" key holds the value of the country name.
    "capital" key holds the value of the capital city name.
    "lat" key holds the value of the latitude coordinate of Paris.
    "lng" key holds the value of the longitude coordinate of Paris.

Please note that this is just a sample JSON object and there could be more information added depending on your specific requirements.

The part that I need is :

{
  "country": "France",
  "capital": "Paris",
  "lat": 48.8566,
  "lng": 2.3522
}

Do you know a method or a library that could extract that JSON for me ? (in PHP)
I know that I could refine my initial query to ChatGPT to no explain anything.
But I prefer to be prepare against eventual strings added in the output.

How to update value of a column based on sum of previous id value of similar date and position, and subtract from different position

This is generated report sorted by date in a table..

This is my current bootstrap table with data from mysql dbase.
I havent done any codes to try the image 2 because I dont really know how to do it. I just know how to display the basic data to tables from mysql database.

Current Output based on my given codes

but this second image is the output or format I am expected to display.

Expected and Sample Output

this is what I wanted to display. base on the attached image.

  1. is the second image possible in PHP MYSQL ?
    given those values from my mysql dbase .. how can I get the output like in the second image? with PHP.

Image 2 Description:

  • the same dates with different values from LEFT Team and RIGHT Team should regroup to each given column and align in the same row.

Example october 18 2022. – LEFT Team has 4 different entries total with of 245 points.
but in the same date there is no entry from RIGHT Team

and so the Balance From left will show 245 and balance right 0 .

  • But since on the next day 10/19/2019
  • there are 3 entries from left total of 130
  • and entries from right team total of 115.
  • 245 + 130 = 375 points
  • the 375 must substract the points from right team who got lower points in totality..
  • 375 – 115 = 260 balance left and Balance right will remain 0 .
  • and same goes to the next dates and so On .

Here’s my Current Code :

$queryupdate=mysqli_query($conn, "SELECT * FROM `tbl_generate_report_all` WHERE user_id = '$currentid'");
    $rowupdate=mysqli_num_rows($queryupdate);
    if($rowupdate>0){
        while($forupdate=mysqli_fetch_array($queryupdate)){

            $theid = $forupdate['id'];
            $thepos = $forupdate['position'];
            $thepoints = $forupdate['points'];

            echo  $theid.' ';
            echo  $thepos.' ';
            echo  $thepoints.' ';

     
        }
    }

    
 
    if(ISSET($_POST['search'])){

        
        $date1 = date("Y-m-d", strtotime($_POST['date1']));
        $date2 = date("Y-m-d", strtotime($_POST['date2']));

        $sql_repsummary = mysqli_query($conn, "SELECT sum(points)as totaldr  FROM `tbl_generate_report_all` WHERE direct_refer = '$currentid' and user_id = '$currentid' and date(`date_activated`) BETWEEN '$date1' AND '$date2'") or die(mysqli_error());
        $row_user_details = mysqli_fetch_assoc($sql_repsummary);
        $thetotaltotaldr = $row_user_details['totaldr'] * 10;


        $query=mysqli_query($conn, "SELECT * FROM `tbl_generate_report_all` WHERE user_id = '$currentid' and date(`date_activated`) 
        BETWEEN '$date1' AND '$date2'") or die(mysqli_error());
        $row=mysqli_num_rows($query);
        if($row>0){
            while($fetch=mysqli_fetch_array($query)){
?>
    <tr>
        <td><?php echo $fetch['date_activated']?>
    </td>
        <td><?php

            $acq_pkg =$fetch['pkg'];

            if ($acq_pkg == 0) {    
                $pkge_column = 'Bronze-15';
                $pkg_value = '15';
                }elseif ($acq_pkg == 1) {
                $pkge_column = 'Silver-30';
                $pkg_value = '30';
                }elseif ($acq_pkg == 2) {
                $pkge_column = 'Gold-60';
                $pkg_value = '60';
                }elseif ($acq_pkg == 3) {
                $pkge_column = 'Platinum-100';
                  $pkg_value = '100';
            }
              
            
            $thepos =$fetch['position'];
            if ($thepos == 'L') {
             echo  $fetch['dl_fullname'] .' - <h5 style="font-size:11px;">'.$pkge_column .'</h5>';
            }else {
                echo '-';
            }



             



              ?></td>
        <td><?php 

$acq_pkg =$fetch['pkg'];

if ($acq_pkg == 0) {    
    $pkge_column = 'Bronze-15';
    $pkg_value = '15';
      }elseif ($acq_pkg == 1) {
    $pkge_column = 'Silver-30';
    $pkg_value = '30';
      }elseif ($acq_pkg == 2) {
    $pkge_column = 'Gold-60';
    $pkg_value = '60';
      }elseif ($acq_pkg == 3) {
      $pkge_column = 'Platinum-100';
      $pkg_value = '100';
}
  

$thepos =$fetch['position'];
if ($thepos == 'R') {
 echo  $fetch['dl_fullname'] .' - <h6 style="font-size:11px;">'.$pkge_column .'</h6>';
}else {
    echo '-';
}



 
        ?></td>
        <td><?php
        if ($thepos == 'L') {
            echo $pkg_value;
        }else {
            echo '-';
        }
            ?></td>

        <td><?php 
        if ($thepos == 'R') {
            echo $pkg_value;
        }else {
            echo '-';
        }
        
        ?></td>
        <td><?php echo $fetch['gc']?></td>
        <td>
            <?php 
            $drid = $fetch['direct_refer'];
            if ($drid == $currentid) {

                echo $pkg_value * 10 ;
            }else {
                echo '-';
            }
            ?>
        
        
        </td>
        <td><?php echo $fetch['total_sm_income']?></td>
    </tr>

     
<?php
            }
        }else{
            echo'
            <tr>
                <td colspan = "4"><center>Record Not Found</center></td>
            </tr>';
        }


    }
?>

In WooCommerce I am getting Time Limit Reached error and it is canceling my order

I am using the plugin of woocommerce for the payment gateway. My client selling the product from out of the country. When users want to buy anything it shows the error “Unpaid order cancelled – time limit reached. Order status changed from Pending payment to Cancelled.”, and the order gets cancelled. Can anyone tell me why this is happening?

Following are the image-

enter image description here

I don’t know what to do.

Uncaught TypeError: preg_match(): Argument #2 ($subject) must be of type string, array given

Hello everyone I need a small help with PHP compatibility with PHP 8.x.

The problem is that with PHP 7.4 everything works fine, but when I upgrade to PHP 8.0 or 8.1 with one specific feature when I do an action I get an error: “There has been a critical error on your website”. The interesting thing is even if I get this error function does its job even after this error.

I have enabled debugging and traced to PHP code:

            // Check with custom fields start
            if ($to_chek_cust_withval != '') {
                $cand_edu_titles_list = get_post_meta($cand_id, 'jobsearch_field_education_title', true);
                $cand_exprience_titles_list = get_post_meta($cand_id, 'jobsearch_field_experience_title', true);
                if (!empty($cand_edu_titles_list)) {
                    foreach ($cand_edu_titles_list as $cand_edu_title) {
                        if ($cand_edu_title != '' && $to_chek_cust_withval != '' && @preg_match("/{$cand_edu_title}/i", $to_chek_cust_withval)) {
                            $validation_arr['custom_field'] = '1';
                            break;
                        }
                    }
                }
                if (!empty($cand_exprience_titles_list)) {
                    foreach ($cand_exprience_titles_list as $cand_exprience_title) {
                        if ($cand_exprience_title != '' && $to_chek_cust_withval != '' && @preg_match("/{$cand_exprience_title}/i", $to_chek_cust_withval)) {
                            $validation_arr['custom_field'] = '1';
                            break;
                        }
                    }
                }
            }
            // Check with custom fields end

And the “main error line – main thrown in” is shown that this is the problem:

 if ($cand_edu_title != '' && $to_chek_cust_withval != '' && @preg_match("/{$cand_edu_title}/i", $to_chek_cust_withval)) {

Can someone help me out with this and give me a fixed PHP line? Please. Thank you.

Tried to search for deprecated functions, Preg in PHP, and more. The syntax is looking good. Could you please check and give a fixed code line?

Call to undefined method AppModelsUser::attachRole() error

Call to undefined method AppModelsUser::attachRole()
I’m absolute beginner with laravel
I’m using “laratrust” package when I’m trying to register it gives me this error and I don’t know why

`<?php

namespace AppHttpControllersAuth;

use AppHttpControllersController;
use AppProvidersRouteServiceProvider;
use AppModelsUser;
use IlluminateFoundationAuthRegistersUsers;
use IlluminateSupportFacadesHash;
use IlluminateSupportFacadesValidator;
use LaratrustTraitsHasRolesAndPermissions;

class RegisterController extends Controller
{
    use RegistersUsers;
    use HasRolesAndPermissions;

    protected $redirectTo = RouteServiceProvider::HOME;

    public function __construct()
    {
        $this->middleware('guest');
    }

    protected function validator(array $data)
    {
        return Validator::make($data, [
            'name' => ['required', 'string', 'max:255'],
            'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
            'password' => ['required', 'string', 'min:8', 'confirmed'],
        ]);
    }
    protected function create(array $data)
    {
        $user = User::create([
            'name' => $data['name'],
            'email' => $data['email'],
            'password' => Hash::make($data['password']),
        ])/*->attachRole('user')*/;
        return  $user->attachRole('admin');
    }
}
`

Unable to open index.php with salted and hashed password [closed]

I am creating register and login page with mysql database/phpmyadmin. I am able to register and login but somehow i cant land on index.php. I tried to redirect both to register.php, login.php and index.php with no avail. Somehow when i logged in i am redirected to register.php over and over again, and if i change redirect to index.php it will say Error, too many redirect.

My codes:

connection.php

<?php

//session_start();
// Tast din host,user, pass og database
//dobbelsjekk om det stemmer

$host="localhost:3306";
$user="root";
$pass="";
$db="dummydb";

$connect = mysqli_connect($host ,$user ,$pass ,$db) or die("Koblingen feil");


?>

functions.php

<?php

function check_login($connect)
{

    if(isset($_SESSION['kundeid']))
    {

        $id = $_SESSION['kundeid'];
        $query = "select * from kunde where kundeid = '$kundeid' limit 1";

        $result = mysqli_query($connect,$query);
        if($result && mysqli_num_rows($result) > 0)
        {

            $kundedata = mysqli_fetch_assoc($result);
            return $kundedata;
        }
    }

    //redirekt til login
    header("Location: register.php");
    die;

}

function random_num($length)
{

    $text = "";
    if($length < 5)
    {
        $length = 5;
    }

    $len = rand(4,$length);

    for ($i=0; $i < $len; $i++) {


        $text .= rand(0,9);
    }

    return $text;
}

?>

register.php

<?php


session_start();

include("connection.php");
include("functions.php");



if($_SERVER['REQUEST_METHOD'] == "POST")
{
  //variabel
  $brukernavn = $_POST['brukernavn'];
  $passord = $_POST['passord'];

  // REGULAR EXPRESSION/ REGEX

  $storbokstav = preg_match('@[A-Z]@', $passord);
  $litenbokstav = preg_match('@[a-z]@', $passord);
  $nummer = preg_match('@[0-9]@', $passord);

  // Hvis du ikke disse kriterier, kan ikke registerer
  if(!$storbokstav || !$litenbokstav || !$nummer ||strlen($passord) <10)
  {
    echo "Passord er ikke sterk nok";
    return;
  }




  // "2nd Part"
  // SALT OG SHA

  $salt = $brukernavn;
  $passord = $_POST['passord'].$salt;
  $passord = sha1($passord);



  // FYLLE INN DATA I Database

  if(!empty($brukernavn) && !empty($passord) && !is_numeric($brukernavn))
  {

    $user_id = random_num(20);
    $sql = "INSERT INTO kunde (brukernavn, passord) VALUES ('$brukernavn', '$passord')";

    mysqli_query($connect, $sql);

    header("Location: login.php");
    die;

  }else{
    echo "Info er ikke riktig";
  }
}




 ?>




 <!DOCTYPE html>
<html>
<head>
<title>Register</title>
</head>
<body>

<style type="text/css">

#text{

height: 25px;
border-radius: 5px;
padding: 4px;
border: solid thin #aaa;
width: 100%;
}

#button{

padding: 10px;
width: 100px;
color: white;
background-color: lightblue;
border: none;
}

#box{

background-color: grey;
margin: auto;
width: 300px;
padding: 20px;
}

</style>

<div id="box">

<form method="post">
<div style="font-size: 20px;margin: 10px;color: white;">Register</div>

<input id="text" placeholder="Brukernavn" type="text" name="brukernavn"><br><br>
<input id="text" placeholder="Passord" type="password" name="passord"><br><br>

<input id="button" type="submit" value="Register"><br><br>

<a href="login.php">Allerede registert? logg inn</a><br><br>
</form>
</div>
</body>
</html>

login.php

<?php

session_start();

    include("connection.php");
    include("functions.php");


    if($_SERVER['REQUEST_METHOD'] == "POST")
    {
        //data er postet
        //$user_name = $_POST['user_name'];
        //$password = $_POST['password'];
        $brukernavn = $_POST['brukernavn'];
        $salt = $brukernavn;
        $passord = $_POST['passord'].$salt;
        $passord = sha1($passord);

        if(!empty($brukernavn) && !empty($passord) && !is_numeric($brukernavn))
        {

            //lese fra database
            $sql = "select * from kunde where brukernavn = '$brukernavn' limit 1";
            $resultat = mysqli_query($connect, $sql);

            if($resultat)
            {
                if($resultat && mysqli_num_rows($resultat) > 0)
                {

                    $kundedata = mysqli_fetch_assoc($resultat);

                    if($kundedata['passord'] === $passord)
                    {

                        $_SESSION['kundeid'] = $kundedata['kundeid'];
                        header("Location: index.php");
                        die;
                    }
                }
            }

            echo "Feil brukernavn eller passord!";
        }else
        {
            echo "Feil brukernavn eller passord!";
        }
    }

?>


<!DOCTYPE html>
<html>
<head>
    <title>Login</title>
</head>
<body>

    <style type="text/css">

    #text{

        height: 25px;
        border-radius: 5px;
        padding: 4px;
        border: solid thin #aaa;
        width: 100%;
    }

    #button{

        padding: 10px;
        width: 100px;
        color: white;
        background-color: lightblue;
        border: none;
    }

    #box{

        background-color: grey;
        margin: auto;
        width: 300px;
        padding: 20px;
    }

    </style>

    <div id="box">

        <form method="post">
            <div style="font-size: 20px;margin: 10px;color: white;">Login</div>

            <input id="text" placeholder="Brukernavn" type="text" name="brukernavn"><br><br>
            <input id="text" placeholder="Passord" type="password" name="passord"><br><br>

            <input id="button" type="submit" value="Login"><br><br>

            <a href="sikkerhet.php">Register her</a><br><br>
        </form>
    </div>
</body>
</html>

index.php

<?php
session_start();

    include("connection.php");
    include("functions.php");

    $kundedata = check_login($connect);

?>

<!DOCTYPE html>
<html>
<head>
    <title>Min website</title>
</head>
<body>

    <a href="logout.php">Logg ut</a>
    <h1>Dette er hovedside</h1>

    <br>
    Hei, <?php echo $kundedata['brukernavn']; ?>
</body>
</html>