Symfony Doctrine :Column Not Added to Table in Database Despite Executing php bin/console doctrine:schema:update –complete –force Command

Column Not Added to Table in Database Despite Executing php bin/console doctrine:schema:update –complete –force Command

The command php bin/console doctrine:schema:update --force is indeed generating entities with fields. However, when I attempted to add a field to an existing entity, it didn’t work as expected. Despite the command being successful in creating initial entities and their fields, it seems to encounter issues when trying to modify existing entities by adding new fields. I’m facing difficulties in updating the schema with additional fields for pre-existing entities.

doctrine.yaml

doctrine:
    dbal:
        driver: pdo_mysql
        host: '%database_host%'
        port: '%database_port%'
        dbname: '%database_name%'
        user: '%database_user%'
        password: '%database_password%'
        # only needed for MySQL
        charset: utf8mb4
        default_table_options:
            collate: utf8mb4_unicode_ci
        mapping_types:
            enum: string
        server_version: 5.7
        # Pour changer le mode sql pour supporter le NONE_FULL_GROUP_BY pour les requêtes sql
        options:
            1002: 'SET sql_mode=(SELECT REPLACE(@@sql_mode, "ONLY_FULL_GROUP_BY", ""))'
        # if using pdo_sqlite as your database driver:
        #   1. add the path in parameters.yml
        #     e.g. database_path: '%kernel.project_dir%/var/data/data.sqlite'
        #   2. Uncomment database_path in parameters.yml.dist
        #   3. Uncomment next line:
        #path: '%database_path%'

    orm:    
        auto_generate_proxy_classes: false
        naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
        auto_mapping: true
        dql:
            string_functions:
                WEEK: DoctrineExtensionsQueryMysqlWeek
                MONTH: DoctrineExtensionsQueryMysqlMonth
                YEAR: DoctrineExtensionsQueryMysqlYear
            datetime_functions:
                TimestampDiff: DoctrineExtensionsQueryMysqlTimestampDiff
        mappings:
            App:
                is_bundle: false
                dir: '%kernel.project_dir%/src/Entity'
                prefix: 'AppEntity'
                alias: App

when@test:
    doctrine:
        dbal:
            # "TEST_TOKEN" is typically set by ParaTest
            dbname_suffix: '_test%env(default::TEST_TOKEN)%'

when@prod:
    doctrine:
        orm:
            auto_generate_proxy_classes: false
            query_cache_driver:
                type: pool
                pool: doctrine.system_cache_pool
            result_cache_driver:
                type: pool
                pool: doctrine.result_cache_pool

    framework:
        cache:
            pools:
                doctrine.result_cache_pool:
                    adapter: cache.app
                doctrine.system_cache_pool:
                    adapter: cache.system

entity:

<?php

namespace AppEntity;

use DoctrineCommonCollectionsArrayCollection;
use DoctrineCommonCollectionsCollection;
use DoctrineDBALTypesTypes;
use DoctrineORMMapping as ORM;

/**
 * Incident_collecte
 * 
 * @author Alaa
 *
 * @ORMTable(name="incident_collecte")
 * @ORMEntity(repositoryClass="AppRepositoryIncidentCollecteRepository")
 * 
 */
class IncidentCollecte
{
 ---------   
    /**
     * @ORMColumn(type="array", nullable=true)
     * 
     * Table des meta-données d'un incident qui permet sa gestion, comme son état précédent
     **/
    private $metaData;

    #[ORMColumn(type: Types::DATETIME_MUTABLE, nullable: true)]
    private ?DateTimeInterface $UpdatedDateStatutFromPortal = null;

/**
     * Get id
     *
     * @return integer
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set dateCreation
     *
     * @param DateTime $dateCreation
     *
     * @return IncidentCollecte
     */
    public function setDateCreation($dateCreation)
    {
        $this->date_creation = $dateCreation;

        return $this;
    }

    /**
     * Get dateCreation
     *
     * @return DateTime
     */
    public function getDateCreation()
    {
        return $this->date_creation;
    }

    /**
     * Set description
     *
     * @param string $description
     *
     * @return IncidentCollecte
     */
    public function setDescription($description)
    {
        $this->description = $description;

        return $this;
    }

    /**
     * Get description
     *
     * @return string
     */
    public function getDescription()
    {
        return $this->description;
    }

    /**
     * Set idDemande.
     *
     * @param int $idDemande
     *
     * @return IncidentCollecte
     */
    public function setIdDemande($idDemande)
    {
        $this->id_demande = $idDemande;

        return $this;
    }

    /**
     * Get idDemande.
     *
     * @return int
     */
    public function getIdDemande()
    {
        return $this->id_demande;
    }

    /**
     * Set dateCloture.
     *
     * @param DateTime|null $dateCloture
     *
     * @return IncidentCollecte
     */
    public function setDateCloture($dateCloture = null)
    {
        $this->date_cloture = $dateCloture;

        return $this;
    }

    /**
     * Get dateCloture.
     *
     * @return DateTime|null
     */
    public function getDateCloture()
    {
        return $this->date_cloture;
    }

    /**
     * Set typeDemande.
     *
     * @param string|null $typeDemande
     *
     * @return IncidentCollecte
     */
    public function setTypeDemande($typeDemande = null)
    {
        $this->type_demande = $typeDemande;

        return $this;
    }

    /**
     * Get typeDemande.
     *
     * @return string|null
     */
    public function getTypeDemande()
    {
        return $this->type_demande;
    }

    /**
     * Set cleDemande.
     *
     * @param string $cleDemande
     *
     * @return IncidentCollecte
     */
    public function setCleDemande($cleDemande)
    {
        $this->cle_demande = $cleDemande;

        return $this;
    }

    /**
     * Get cleDemande.
     *
     * @return string
     */
    public function getCleDemande()
    {
        return $this->cle_demande;
    }

    /**
     * Set raisonCloture.
     *
     * @param string|null $raisonCloture
     *
     * @return IncidentCollecte
     */
    public function setRaisonCloture($raisonCloture = null)
    {
        $this->raison_cloture = $raisonCloture;

        return $this;
    }

    /**
     * Get raisonCloture.
     *
     * @return string|null
     */
    public function getRaisonCloture()
    {
        return $this->raison_cloture;
    }

    /**
     * Set priorite.
     *
     * @param string $priorite
     *
     * @return IncidentCollecte
     */
    public function setPriorite($priorite)
    {
        $this->priorite = $priorite;

        return $this;
    }

    /**
     * Get priorite.
     *
     * @return string
     */
    public function getPriorite()
    {
        return $this->priorite;
    }

    /**
     * Set etat.
     *
     * @param string $etat
     *
     * @return IncidentCollecte
     */
    public function setEtat($etat)
    {
        $this->etat = $etat;

        return $this;
    }

    /**
     * Get etat.
     *
     * @return string
     */
    public function getEtat()
    {
        return $this->etat;
    }

    /**
     * Set regle.
     *
     * @param string|null $regle
     *
     * @return IncidentCollecte
     */
    public function setRegle($regle = null)
    {
        $this->regle = $regle;

        return $this;
    }

    /**
     * Get regle.
     *
     * @return string|null
     */
    public function getRegle()
    {
        return $this->regle;
    }

    /**
     * Set DatePriseEnCompteClient.
     *
     * @param DateTime|null $datePriseEnCompteClient
     *
     * @return IncidentCollecte
     */
    public function setDatePriseEnCompteClient($dateMajClient = null)
    {
        $this->date_prise_en_compte_client = $dateMajClient;

        return $this;
    }

    /**
     * Get DatePriseEnCompteClient.
     *
     * @return DateTime|null
     */
    public function getDatePriseEnCompteClient()
    {
        return $this->date_prise_en_compte_client;
    }

    /**
     * Set impact.
     *
     * @param string|null $impact
     *
     * @return IncidentCollecte
     */
    public function setImpact($impact = null)
    {
        $this->impact = $impact;

        return $this;
    }

    /**
     * Get impact.
     *
     * @return string|null
     */
    public function getImpact()
    {
        return $this->impact;
    }

    /**
     * @return Collection|Siiv[]
     */
    public function getSiiv(): Collection
    {
        return $this->siiv;
    }

    public function addSiiv(Siiv $siiv): self
    {
        if (!$this->siiv->contains($siiv)) {
            $this->siiv[] = $siiv;
        }

        return $this;
    }

    public function removeSiiv(Siiv $siiv): self
    {
        $this->siiv->removeElement($siiv);

        return $this;
    }

    /**
     * Set collecteurLogs.
     *
     * @param string|null $collecteurLogs
     *
     * @return IncidentCollecte
     */
    public function setCollecteurLogs($collecteurLogs = null)
    {
        $this->collecteur_logs = $collecteurLogs;

        return $this;
    }

    /**
     * Get collecteurLogs.
     *
     * @return string|null
     */
    public function getCollecteurLogs()
    {
        return $this->collecteur_logs;
    }

    /**
     * Set metaData.
     *
     * @param array|null $metaData
     *
     * @return IncidentCollecte
     */
    public function setMetaData($metaData = null)
    {
        $this->metaData = $metaData;

        return $this;
    }

    /**
     * Get metaData.
     *
     * @return array|null
     */
    public function getMetaData()
    {
        return $this->metaData;
    }

    /**
     * @return string|null
     */
    public function getNumoffense(): ?string
    {
        return $this->numoffense;
    }

    /**
     *
     * @param string|null $numoffense
     * @return IncidentCollecte
     */
    public function setNumoffense(?string $numoffense): IncidentCollecte
    {
        $this->numoffense = $numoffense;

        return $this;
    }

    /**
     * @return string|null
     */
    public function getSeverity(): ?string
    {
        return $this->severity;
    }

    /**
     * @param string|null $severity
     * @return IncidentCollecte
     */
    public function setSeverity(?string $severity): IncidentCollecte
    {
        $this->severity = $severity;

        return $this;
    }

    public function getUpdatedDateStatutFromPortal(): ?DateTimeInterface
    {
        return $this->UpdatedDateStatutFromPortal;
    }

    public function setUpdatedDateStatutFromPortal(?DateTimeInterface $UpdatedDateStatutFromPortal): static
    {
        $this->UpdatedDateStatutFromPortal = $UpdatedDateStatutFromPortal;

        return $this;
    }
}

Docker Php and apache install Composer

I want to start project and make my own framework for technical future work test, so i want to install composer for install some library, but when i execut

docker-compose exec php bash

terminal say to me service “php” is not running

My question is : What is the right container for running composer ? apache, php ? Create a composer container ?

I have docker-compose.yml

version: "3.8"
services:
  apache:
    container_name: apache
    build: ./docker/apache
    links:
      - php
    ports:
      - "81:80"
    volumes:
      - ./src:/usr/local/apache2/htdocs
  php:
    container_name: php
    build: ./docker/php
    ports:
      - "9000:9000"
    volumes:
      - ./src:/usr/local/apache2/htdocs
    working_dir: /usr/local/apache2/htdocs

with Docker file for apache

// apache/Dockerfile

FROM httpd:2.4.51

COPY apache.conf /usr/local/apache2/conf/apache.conf

RUN echo "Include /usr/local/apache2/conf/apache.conf" 
    >> /usr/local/apache2/conf/httpd.conf

with apache.conf

LoadModule deflate_module /usr/local/apache2/modules/mod_deflate.so
LoadModule proxy_module /usr/local/apache2/modules/mod_proxy.so
LoadModule proxy_fcgi_module /usr/local/apache2/modules/mod_proxy_fcgi.so

<VirtualHost *:80>
    ProxyPassMatch ^/(.*.php(/.*)?)$ fcgi://php:9000/usr/local/apache2/htdocs/$1

    DocumentRoot /usr/local/apache2/htdocs

    <Directory /usr/local/apache2/htdocs>
        Options -Indexes +FollowSymLinks
        DirectoryIndex index.php
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

and DockerFile for PHP with COMPOSER installation

FROM php:8.1-fpm
WORKDIR /var/www

RUN apt-get update
RUN docker-php-ext-install pdo pdo_mysql mysqli

RUN apt-get install -y autoconf pkg-config libssl-dev
RUN pecl install mongodb
RUN echo "extension=mongodb.so" >> /usr/local/etc/php/conf.d/mongodb.ini

COPY --from=composer /usr/bin/composer /usr/bin/composer

Log in issue – PHP and HTML [closed]

php

html

enter image description here

I just started PHP and try to make simple project about log in below you can able to see code of HTML and also PHP, I also make data based I added data as well.

So the issue I face is basically when I enter the correct details I mean password it show me same message that your password is incorrectly and I don’t know the issue might be password_hash have issue not sure.

Data base HTML PHP

Data Based, I added the image of that data base one.

Username is 1234 and password is also 1234 not working at all could you please help out to fix that issue for me. Thank you so much.

I try everything I changed all the code but still not working and also I use default hash option that also not working. what I’m expecting that what is issue on this code or what causes that issue that if I even enter the correct details it show me incorrect password

HTML2PDF not handling display: none

I’m trying to use the HTML2PDF PHP library to generate a PDF starting from a complex HTML page. The PDF is being generated successfully, but the HTML elements of my source page that have style="display: none" are being displayed in the PDF. I need the elements that have display: none in the HTML to also be hidden in the PDF.

I thought that maybe HTML2PDF was failing to read the CSS class, so I moved the display: none to inline, but this did not solve the problem.

Then I thought maybe HTML2PDF couldn’t read inline stiles either, but when I changed the inline style to text-decoration: underline the text was actually underlined in the PDF!

Is it possible that the display CSS property is ignored?

How to fix PHP Image won’t load, and CSS won’t work

does anybody know how to fix this?
I’m using Xampp and Visual Studio Code, and when I try to link my CSS to PHP and run, only the html can be seen and the CSS won’t show up. Also, when I try to use and run, img won’t load. Please help me 🙁

I tried following steps in Youtube. But none of them work.

Here's the problem in image.

TCPDF and NOBR, struggling to make it work

I’m trying to produce a PDF using TCPDF, and generally speaking everything is fine. I am producing a list of vehicles, and a couple of lists of information about each vehicle. These are created in the form of individual HTML tables. This works as expected, but with the problem that page breaks can occur within a vehicle record – so I might get the header at the bottom of the page, and the other two tables on the next page.

I’ve done a bit of reading and found that there are two options, either to set the `page-break-inside: avoid’, or to add ‘nobr=true’. I’ve found that for these to work, I have to set K_TCPDF_CALLS_IN_HTML to be true, I have done that and if I echo that value, it is set to 1. I am aware that TCPDF only parses parameters which are set with ” quotes rather than ‘ quotes. I have tried both methods in a div surrounding each vehicle record, and each time it makes no difference, the div is just split across a page if required. I have tried removing the font changes in case that breaks the div, but it didn’t help.

Here is a summary of my code, the TCPDF stuff is all pretty much based on the first example from their web site:

<?php
include("my_database.php");

// Include the main TCPDF library (search for installation path).
require_once('vendor/tecnickcom/tcpdf/tcpdf.php');

// Get the model details
$model_id = $_POST['model_id'];
$q1 = "select model, make from car_models left join car_makes on car_models.make_id = car_makes.id where car_models.model_id = ?";
$prep = $dbc->prepare($q1);
$ex = $prep->execute(array($model_id));
$model = $prep->fetchAll();
if (count($model) > 0) {
    $mname = $model[0]['make'] . " " . $model[0]['model'];

    $query = "select car_id from cars where model_id = ? and (hidden <> 2) order by registration";
    $prep = $dbc->prepare($query);
    $ex = $prep->execute(array($model_id));
   if ($ex) {
    $cars = $prep->fetchAll();
    $vehcount = count($cars);

    // create new PDF document
    $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
    
    // set document information
    $pdf->SetCreator(PDF_CREATOR);
    $pdf->SetAuthor('My Name');
    $pdf->SetTitle('My vehicle List');
    $pdf->SetSubject('Vehicle List');
    $pdf->SetKeywords('cars, list');
    
    // set default header data
    $pdf->SetHeaderData("mylogo.png", 40, 'My vehicle Register', $mname . " - " . $vehcount . " recorded", array(0,64,255), array(0,64,128));
    $pdf->setFooterData(array(0,64,0), array(0,64,128));
    
    // set header and footer fonts
    $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
    $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
    
    // set default monospaced font
    $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
    
    // set margins
    $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
    $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
    $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
    
    // set auto page breaks
    $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
    
    // set image scale factor
    $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
    
    // set some language-dependent strings (optional)
    if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
        require_once(dirname(__FILE__).'/lang/eng.php');
        $pdf->setLanguageArray($l);
        }
    
    // ---------------------------------------------------------
    
    // set default font subsetting mode
    $pdf->setFontSubsetting(true);
    
    // Add a page
    // This method has several options, check the source code documentation for more information.
    $pdf->AddPage();
    
    // I've tried both of these, without success.
    //$pbopen = "<div style="page-break-inside:avoid;">";
    $pbopen = "<div nobr="true">";
    $pbclose = "</div>";
    
    foreach($cars as $car) {
        $carinfo = getCarInfoAsHTML($dbc, $car['car_id']);
        
if (is_array($carinfo)) {
        $pdf->SetFont('helvetica', '', 14, '', true);

    $pdf->writeHTML($pbopen . $carinfo['header'], true, false, false, false, '');
    
    $pdf->SetFont('helvetica', '', 10, '', true);
    $pdf->writeHTML($carinfo['owner'], true, false, false, false, '');
    $pdf->writeHTML($carinfo['notes'], true, false, true, false, '');
    $pdf->writeHTML("<hr />" . $pbclose, true, false, true, false, '');
    
    
    // ---------------------------------------------------------
    
    // Close and output PDF document
    // This method has several options, check the source code documentation for more information.
    
    }
    else {
        echo "Car not found. ";
        }
    }
        $pdf->Output($mname . ".pdf", 'I');

}
}
else {
echo "Invalid model id";
}   

?>

I’ve taken out stuff that I think is irrelevant here, but I hope I’ve left enough in place to help someone see what I’m doing incorrectly. This is typical (but edited for privacy) of what each string returned will contain:

  'header' => string '<table cellspacing='0' cellpadding='1'><tr><td style="width: 30%">Registration</td><td style="width: 70%">ABC 123V </td></tr><tr><td>Date of Registration</td><td></td></tr><tr><td>Model</td><td>Ford Fiesta</td></tr><tr><td>VIN</td><td> / </td></tr><tr><td>Last VED / MOT / V5</td><td>SORN / Not recorded / </td></tr></table>' (length=334)
  'owner' => string '<h3>Owner Sequence</h3><table><tr><th style="width: 10%">&nbsp;</th><th style="width: 32%">Owner</th><th style="width: 20%">Area</th><th style="width: 18%">From</th><th>To</th></tr><tr><td>1</td><td>Bill Clinton</td><td>Northern Ireland</td><td></td><td></td></tr></table>' (length=279)
  'notes' => string '<h3>Notes</h3><table><tr><th style="width: 25%">Date</th><th style="width: 75%">Notes</th></tr><tr><td style="width:25%;">&nbsp;</td><td style="width: 75%">Rally car. </td></tr><tr><td style="width: 25%;">2023-03-20</td><td style="width: 75%">Last-taxed-date changed from '' to 'SORN'</td></tr></table>' (length=306)

My code should therefore create a separate <div> for each vehicle, inside which is one, two or three HTML tables (not all have a list of owners, or any notes). It works well, but it splits a vehicle record across a page break which I’d like to avoid. I’m sure I am missing something simple, but I can’t see what it is.

WooCommerce Configure the Product List Display

I am trying to figure out a way to display the information of the products differently but not to sort them on this matter.

Currently it is showing first product_name then product_price and last it shows product_stock.

I would want to show the information in this order instead product_name, product_stock and after product_price.

I added a code snippet to force the product_stock to appear on the product list page.

Do i need to do something similar to force the display the way i want or is this locked by woocommerce?

Thanks for any information

A redirection problem in my PHP proxy server for loading webpages

I have a proxy server written in PHP for a browser in a browser project, but when inside something like google.com and I tried doing a search inside the proxy server, it’s going to take me to “proxyserver/search?q=hi” instead of the expected result which is “proxyserver/proxy.php?url=https://google.com/search?q=hi”

Basically the main problem is if a site rendered inside the proxy server tried taking me from /pageone to /pagetwo, it takes me from “proxyserver/proxy.php?url=https://example.com/pageone” to “proxyserver/pagetwo”

I tried pretty much everything to fix this, but it for some reason wouldn’t work so I just reverted back to the old code that still has the bug.

Full code:

ob_start("ob_gzhandler");
ini_set('memory_limit', '128M');
session_start();

$cookieFile = 'cookies.txt';

if (!isset($_COOKIE['PHPSESSID'])) {
    clearCookies();
}

if ($_SERVER['REQUEST_METHOD'] === 'GET' && isset($_GET['url'])) {
    $url = $_GET['url'];
    proxyRequest($url);
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['url'])) {
    $url = $_POST['url'];
    $postData = http_build_query($_POST);

    echo "Debug: POST URL - " . $url . "<br>";
    echo "Debug: POST Data - " . $postData . "<br>";

    if (isset($_GET['url'])) {
        $url = $_GET['url'];
        echo "Debug: Using GET URL - " . $url . "<br>";
    }

    if (!filter_var($url, FILTER_VALIDATE_URL)) {
        echo "Error: Invalid URL.";
        exit;
    }

    proxyRequest($url, $postData);
} else {
    echo "Debug: Invalid request received. ";
    echo "Debug: GET Data - " . json_encode($_GET) . "<br>";
    echo "Debug: POST Data - " . json_encode($_POST) . "<br>";

    echo "Error: Invalid request.";
}

function proxyRequest($url, $postData = null) {
    header('Content-Type: text/html');
    header('Access-Control-Allow-Origin: *');

    global $cookieFile;

    $customDNS = [
        'example.com:80:1.1.1.1',
        'example.com:443:8.8.8.8',
    ];

    $ch = curl_init($url);

    $options = [
        CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36',
        CURLOPT_HTTPHEADER => [
            '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',
            'Accept-Language: en-GB',
            'Accept-Encoding: gzip, deflate',
            'Dnt: 1',
            'Sec-GPC: 1',
            'Sec-Fetch-Dest: document',
            'Sec-Fetch-Mode: navigate',
            'Connection: keep-alive',
            'Upgrade-Insecure-Requests: 1',
        ],
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_AUTOREFERER => true,
        CURLOPT_ENCODING => '',
        CURLOPT_TIMEOUT => 10,
        CURLOPT_SSL_VERIFYPEER => false,
        CURLOPT_SSL_VERIFYHOST => false,
        CURLOPT_RESOLVE => $customDNS,
    ];

    if ($_SERVER['REQUEST_METHOD'] === 'POST') {
        $options[CURLOPT_POST] = true;
        $options[CURLOPT_POSTFIELDS] = $postData;
    }

    if (isset($_COOKIE['PHPSESSID'])) {
        $options[CURLOPT_COOKIEJAR] = $cookieFile;
        $options[CURLOPT_COOKIEFILE] = $cookieFile;
    }

    curl_setopt_array($ch, $options);

    $content = curl_exec($ch);

    if ($content !== false) {
        preg_match_all('/Set-Cookie: (.*?);/i', $content, $matches);
        $receivedCookies = implode('; ', $matches[1]);

        file_put_contents($cookieFile, $receivedCookies);

        error_log('Received content: ' . $content);

        echo $content;
    } else {
        error_log('Error: Unable to fetch content from the external website. cURL Error: ' . curl_error($ch));

        echo "Error: Unable to fetch content from the external website. cURL Error: " . curl_error($ch);
    }

    curl_close($ch);
}

function clearCookies() {
    global $cookieFile;
    if (file_exists($cookieFile)) {
        unlink($cookieFile);
    }
}
?>

How to skip first value in php preg_match [duplicate]

I want to preg_match between a and guy but i also want to SKIP the first preg_match value and preg_match start from 2nd value then continue. and the values between a and guy could be anything so please don’t focus on the words i example here, just preg_match the between a and guy. and $string contain unlimited sentences. i don’t know the exact number of sentences.

$string = "this is a small guy , this is a tall guy, this is a big guy, this is a fat guy, This is a bad guy, This is a mad guy,  Sentences are continue....";

So i want to skip the first value which i mentined the word small here but it could be anything so skip the first value between a and guy.

How do I get Apache to run on XAMPP

I’ve been trying to start apache on xampp but I keep getting this error message

You need to uninstall/disable/reconfigure the blocking application
12:45:52 PM  [Apache]   or reconfigure Apache and the Control Panel to listen on a different port
12:45:52 PM  [Apache]   Problem detected!
12:45:52 PM  [Apache]   Port 443 in use by "Unable to open process" with PID 25792!
12:45:52 PM  [Apache]   Apache WILL NOT start without the configured ports free!
12:45:52 PM  [Apache]   You need to uninstall/disable/reconfigure the blocking application
12:45:52 PM  [Apache]   or reconfigure Apache and the Control Panel to listen on a different port

My default port is port 80 so I don’t understand why I am getting the error. I can’t see any services or applications using port 443 and when I try to reconfigure to port to 8080 it still doesn’t work. Im stuck and I don’t know what else to try.

Changes in captcha image through coding

I use the following captcha code which works correctly:

<?php
session_start();
//You can customize your captcha settings here

$captcha_code = '';
$captcha_image_height = 50;
$captcha_image_width = 130;
$total_characters_on_image = 6;

//The characters that can be used in the CAPTCHA code.
//avoid all confusing characters and numbers (For example: l, 1 and i)
$possible_captcha_letters = 'bcdfghjkmnpqrstvwxyz23456789';
$captcha_font = './monofont.ttf';

$random_captcha_dots = 45;
$random_captcha_lines = 20;
$captcha_text_color = "0x021f64";
$captcha_noise_color = "0x021f64";


$count = 0;
while ($count < $total_characters_on_image) { 
$captcha_code .= substr(
    $possible_captcha_letters,
    mt_rand(0, strlen($possible_captcha_letters)-1),
    1);
$count++;
}

$captcha_font_size = $captcha_image_height * 0.65;
$captcha_image = @imagecreate(
    $captcha_image_width,
    $captcha_image_height
    );

/* setting the background, text and noise colours here */
$background_color = imagecolorallocate(
    $captcha_image,
    255,
    255,
    255
    );

$array_text_color = hextorgb($captcha_text_color);
$captcha_text_color = imagecolorallocate(
    $captcha_image,
    $array_text_color['red'],
    $array_text_color['green'],
    $array_text_color['blue']
    );

$array_noise_color = hextorgb($captcha_noise_color);
$image_noise_color = imagecolorallocate(
    $captcha_image,
    $array_noise_color['red'],
    $array_noise_color['green'],
    $array_noise_color['blue']
    );

/* Generate random dots in background of the captcha image */
for( $count=0; $count<$random_captcha_dots; $count++ ) {
imagefilledellipse(
    $captcha_image,
    mt_rand(0,$captcha_image_width),
    mt_rand(0,$captcha_image_height),
    2,
    3,
    $image_noise_color
    );
}

/* Generate random lines in background of the captcha image */
for( $count=0; $count<$random_captcha_lines; $count++ ) {
imageline(
    $captcha_image,
    mt_rand(0,$captcha_image_width),
    mt_rand(0,$captcha_image_height),
    mt_rand(0,$captcha_image_width),
    mt_rand(0,$captcha_image_height),
    $image_noise_color
    );
}

/* Create a text box and add 6 captcha letters code in it */
$text_box = imagettfbbox(
    $captcha_font_size,
    0,
    $captcha_font,
    $captcha_code
    ); 
$x = ($captcha_image_width - $text_box[4])/2;
$y = ($captcha_image_height - $text_box[5])/2;
imagettftext(
    $captcha_image,
    $captcha_font_size,
    0,
    $x,
    $y,
    $captcha_text_color,
    $captcha_font,
    $captcha_code
    );

/* Show captcha image in the html page */
// defining the image type to be shown in browser widow
header('Content-Type: image/jpeg'); 
imagejpeg($captcha_image); //showing the image
imagedestroy($captcha_image); //destroying the image instance
$_SESSION['captcha'] = $captcha_code;

function hextorgb ($hexstring){
  $integar = hexdec($hexstring);
  return array("red" => 0xFF & ($integar >> 0x10),
               "green" => 0xFF & ($integar >> 0x8),
               "blue" => 0xFF & $integar);
               }
?>

Result of above code:
Generated captcha image

As you can see in the image, the generated image for captcha has only one color, which is very annoying.

I want each part of the generated captcha image to have different colors so that it looks beautiful in addition to making it harder for robots to guess it.

What I’m looking for is to generate the captcha image as follows:
My desired captcha image

Is there a need for a separate library to generate such a captcha image or can it be implemented with a few changes in the code?

html+js fileInputForm with accept(sql) and SafeTable(with sql in html)

Good day dear!

I want to implement such a system in myself, but I cannot understand how to do it correctly. I know many points, but I don’t know how to put them together.

What do I want?

A person clicks on the button to insert his file, after which a request with a binary question is immediately created in the data base: confirm? yes(1) or no(2). For example, I choose the number 1 (yes), after which the file is sent to the server, and the person’s dialog box changes to the fact that his file has already been sent.

sql php my admin mariadb

If not, the file is not sent and the person is returned a cancellation message.

*If it’s not clear, write in the comments, please) it’s very difficult to explain to me, the point is that a person would store his data and files on our server, but he did it with a check from our administration.
*
for user

I tried the input method, but it works crookedly with the server.

How do I set question types for a survey in a database

So I’m creating a website that conducts a survey and i have the questions in a schema some of them have choices and some don’t and i want to create a database for them so how do i do it

Created a table for the questions but had problem in setting the question types

Hi, I am facing an issue in laravel livewire listner not working

namespace AppHttpLivewireSurvey;

use LivewireComponent;
use AppModelsSection as SectionModel;

class Section extends Component
{
    public $questionnaireId;
    public $section;
    public $currentSection = 0;
    public $listeners = ['nextSection'];

    public function nextSection()
    {
        $this->currentSection++;
        $this->currentSection = $this->getSections($this->currentSection);
    }

    public function getSections($offset = 0)
    {
        $this->section = SectionModel::where('questionnaire_id', $this->questionnaireId)->offset($offset)->first();
    }

    public function mount($questionnaireId)
    {
        $this->questionnaireId = $questionnaireId;
        $this->getSections();
    }

    public function getSectionsProperty()
    {
        return $this->section;
    }
}

This is my componentOne.php

public function triggerNextSection()
{
    $this->emit('nextSection');
}

This is component-one.blade.php

<button wire:click="triggerNextSection"
        class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded"> Continue
</button>

while click on the button continue, $currentSection value is increased by 1.

Same way I used this button and emit this event in componentTwo, Here not incrementing the value of $currentSection.

Can anyone please help how should I increment this varible value?

I tried to emit an event with passing parameters