How to make backend of a web app on Android?

I do not have a laptop or desktop .So, I code only on mobile and made a tic-tac-toe game using html,css and javascript and now I want that whenever I open that game it asks me who am I and give me option to select the user ,which have played before or create a new user and so that how many times .I have won , lost or tied.So, I need a database but as mentioned above I cannot use libraries or mySQL or other databases because they cannot be installed on mobile.I currently just want a simple database or even a way to create a database on mobile.Please tell me what to do.If with answer a post of code that can store a username or anything to help me understand will be appreciated.

I tried using php and SQLite and localstorage but the localstorage did not work and I am not able to understand SQLite.

Can’t send emails implements ShouldQueue using filamentphp and laravel

i have problems sending email when implements ShouldQueue, if i not implement ShouldQueue the emails is sended, but not when use ShouldQueue, this is my MailNotification

<?php

namespace AppMail;

use IlluminateBusQueueable;
use IlluminateContractsQueueShouldQueue;
use IlluminateMailMailable;
use IlluminateQueueSerializesModels;

use AppModelsCompanyEntrustRegistration;

class EntrustRegistrationNotification extends Mailable implements ShouldQueue
{
    use Queueable, SerializesModels;

    public EntrustRegistration $registration;
    public string $action;

    /**
     * Create a new message instance.
     */
    public function __construct(EntrustRegistration $registration, string $action)
    {
        $this->registration = $registration;
        $this->action = $action;
    }

    public function build()
    {
        return $this->view('emails.entrust_registration_notification')
                    ->with([
                        'registration' => $this->registration,
                        'action' => $this->action,
                    ])
                    ->subject("Se ha {$this->action} una encomienda");
    }

}

and i have this model

<?php

namespace AppModelsCompany;

use AppMailEntrustRegistrationNotification;
use AppModelsCompany;
use FilamentModelsContractsHasTenants;
use FilamentPanel;
use IlluminateContractsDatabaseEloquentBuilder;
use IlluminateDatabaseEloquentFactoriesHasFactory;
use IlluminateDatabaseEloquentModel;
use IlluminateDatabaseEloquentRelationsBelongsTo;
use IlluminateSupportCollection;
use IlluminateSupportFacadesMail;

class EntrustRegistration extends Model implements HasTenants
{
    use HasFactory;

    protected $fillable = [
        'nombreca',
        'tipoencomienda',
        'estado',
        'coowner_id',
        'company_id',
    ];

    protected static function booted(): void
    {
        // Event for Send Emails
        self::created(function ($registration) {
            $registration->load('coowners.guest');
            Mail::to($registration->coowners->guest->email)
                ->queue(new EntrustRegistrationNotification($registration, 'recibido'));
        });

        self::updated(function ($registration) {
            $registration->load('coowners.guest');
            Mail::to($registration->coowners->guest->email)
                ->queue(new EntrustRegistrationNotification($registration, 'actualizado'));
        });
    }

    public function companies(): BelongsTo
    {
        return $this->belongsTo(Company::class, 'company_id');
    }

    public function getTenants(Panel $panel): array|Collection
    {
        return $this->companies;
    }

    public function canAccessTenant(Model $tenant): bool
    {
        return $this->companies->contains($tenant);
    }

    public function coowners(): BelongsTo
    {
        return $this->belongsTo(Coowner::class, 'coowner_id');
    }
}

For some reason when using implements ShouldQueue it does not take the email of the coowners->guest relationship that exists in my coowner model, this is my relationship in the coowner model

    public function guest(): BelongsTo
    {
        $tenant = Filament::getTenant(); // Obtener el inquilino actual
        return $this->belongsTo(Guest::class, 'guest_id')->whereHas('companies', function ($query) use ($tenant) {
            $query->where('id', $tenant->id); // Filtrar los huéspedes relacionados con el inquilino actual
        });
    }

i try adding this line but is not working

$registration->load('coowners.guest');

i can-t understand what going on now, i have my .env with QUEUE_CONNECTION=database

How Delete comments by author comment with id? [closed]

How Delete comments by author comment with id page? using php and mysql

I have a table guestbook for users , Everything is fine but there’s a thing cant do it , How I allowing user to delete his comment later?

Example :>>>

User (A) Has commented Test Good (id row table comment 133)
User (A) Has commented Test Nice (id row table comment 632)

User (B) Has commented Test 2 (id row table comment 12312)

User (C) Has commented Test 3 (id row table comment 131 )

My Id page url for comments testcomment.php?id=1

How allow Session User(A) .Show Text (Delete button ) for test Good and Nice comment , And Hide this Delete Button for other one
I need Delete Comment for every author

Im using dreamweaver cs6

I looked for everything but tired

Php 8 session id resets on page refresh (or when I change page)

Every time I change page or refresh the page I lose all my sessions variables, after while I figured out it was caused by the session id that changes everytime (I think it is because of this). Something strange, is that for a day the session id stopped changing and it worked and then again, it doesn’t work anymore.
Here is my config session file :

<?php

ini_set("session.use_only_cookies", 1);
ini_set("session.use_strict_mode", 1);

session_set_cookie_params([
    "lifetime" => 1800,
    "domain" => "localhost",
    "path" => "/", // session marche partout
    "secure" => true, // marche seulement avec une connexion https
    "httponly" => true, // l'utilisateur ne puisse pas changer les cookies avec un script de hack
]);

session_start();

How to get image url from sql

My sql cell contains

{"thumbnail":{"url":"https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDQigGygNrDSie20W7XnoHFM3vcKnZthRrxkOU2AxfnM_1p6J7bkmVTlEssDol7CGi15QMdiiRdF4C1W-EgCgKVhWr7uhLx58cP52X2PZNEbRsORlijMU7r1tN5V0fUdjaoEez91b8ISgzYeutpr9J42qIDIJOoQp1WFGUN4i6rpEIb8uwK_O4P0BwEj1g/s72-w384-h511-c/NavaTelanganaClipping.jpeg","height":"72","width":"72"},"enclosures":[]}

I want to get only image url ,, it may either jpg or png

I did

$str = $row["attributes"];
$rem = array(
'enclosures',
'[',
'thumbnail',
':]}',
'"',
'{',
'height',
'width',
'}',
':',
',',
'url',
'72',
'https'

);

$str = str_replace($rem, “”, $str);
echo “<img src=””.$str.” />”;

i want to authinticate users to a specific page using laravel

i want to make a authentication system when a user login they should be taken to a specific page, like a profile or dashboard?

how should i do it using laravel framework 11.

i haven’t tried anything yet because i am fairly new to this framework.

i have a login page set in the framework but i was wondering to authenticate users to a dashboard or a page.

what are the best options i can go with, if there is any tutorials that would help me make this happen would be appreciated.

thank you in advance.

Laravel keep logging user out the first time, the second time user login it will run normally

Previously my website is already working normally but for some reason we need to re-import the file with clean file (backup) and after that this problem keep happening, what have i done is :

  1. change the session type from file to database
  2. clear all data cache data in storage
  3. Restarting apache server
  4. php artisan also
  5. Check the cloudflare but it use DNS so it’s not cloudflare problem
  6. not using any load balancer
  7. also checking server firewall and they say it’s working normally
  8. changing cookie name
  9. triple check that lifetime is still 120

i also already check laravel.log but there’s nothing
i’m using Laravel 7.4

can someone tell me what’s wrong with this? it work normally before we use backup file, oh i’m using AWS

PHP combine two associative arrays with different keys

I want to combine two associative arrays with different amount of keys and keep all the keys in the final array even if they are null or empty

I have tried array_merge but the keys that are not present in both arrays are removed.

Here are the two arrays:

$array1 = array(
    array("email" => "user1@mail", "login" => "user1", "phone" => "123", "color" => "red"),
    array("email" => "user2@mail", "login" => "user2", "phone" => "456", "color" => "blue"),
);

$array2 = array(
    array("email" => "user3@mail", "login" => "user3"),
    array("email" => "user4@mail", "login" => "user4"),
);

And this is what I want to get:

$arrayMerge = array(
    array("email" => "user1@mail", "login" => "user1", "phone" => "123", "color" => "red"),
    array("email" => "user2@mail", "login" => "user2", "phone" => "456", "color" => "blue"),
    array("email" => "user3@mail", "login" => "user3", "phone" => NULL, "color" => NULL),
    array("email" => "user4@mail", "login" => "user4", "phone" => NULL, "color" => NULL),
);

The value NULL could also be empty, all I want is to keep the key.

How to access ACF option’ sub-field outside of the option page?

My homepage has embedded an ACF option page, which included two feature banners.
From dump() of the large feature banner, I got this array (showing parts that are relevant to this q):

array:24 [
......
 "featureBanners" => array:2 [▼
    0 => {#3489 ▼
      +"url": "https://wordpress.test/2024/3/latest-drops"
      +"shop_url": "https://wordpress.test/shop/latest-drops"
    }
    1 => {#3488 ▼
      +"url": "https://wordpress.test/2024/3/sale"
      +"shop_url": "https://wordpress.test/shop/sale"
    }
  ]
  "bannerSetting" => {#3489 ▼
    +"url": "https://wordpress.test/2024/3/sale"
    +"shop_url": "https://wordpress.test/shop/latest-drops"
......
]

I have added a “Shop Now” button on the url page.
When I’m on the url page and use dump(), there’s no “featureBanners” and “bannerSetting” displayed on the array. I need to access the “shop_url” sub-field in order to link the button to the url.

On homepage, I’ve used get_feature_post_url function to get the shop_url sub-field

{% if bannerPost.id is defined %}
......
   {% set shopUrl = get_feature_post_url(bannerSetting.shop_url) %}
......
{% endif %}

Related twig functions in ArchiveHelperExtension.php:

public function getFunctions(): array
{
   return [
     ......
      new TwigFunction('editorial_feature_posts', [$this, 'getFeaturePosts']),
      new TwigFunction('get_feature_post_url', [$this, 'getFeaturePostUrl']),
    ......
   ]
}

I was trying to access an ACF option’s sub-field shop_url outside of the option page. Expected to see bannerSetting on the actual url page as well but could not see it and so unable to access the shop_url as well.

Sorry really spent hours thinking on this.
Please let me know what can I do to fix this?
Much appreciated!

How to use headless Chrome in Docker?

Currently I’m using MPDF to convert complicated html files to pdf with PHP Laravel (production server is Ubuntu 22.04 and development is Docker image with Ubuntu 22.04). I would like to improve the conversion quality and try to use conversion based on Google Chrome features.

Added chromium-browser install into dockerfile: apt-get install -y chromium-browser

And trying to run this code:

$browser = (new BrowserFactory('chromium-browser'))->createBrowser(['windowSize' => [1920, 1080]]);

$page = $browser->createPage();
$page->setHtml($html);

return base64_decode(
  $page->pdf([
    'printBackground' => true
  ])->getBase64()
);

Getting error: Chrome process stopped before startup completed. Additional info: Command ‘/usr/bin/chromium-browser’ requires the chromium snap to be installed. Please install it with: snap install chromium

When I try to execute command snap install chromium getting error error: cannot communicate with server: Post “http://localhost/v2/snaps/chromium”: dial unix /run/snapd.socket: connect: no such file or directory

How can I use headless Chrome with Ubuntu in docker and without docker (in production)?
Thank you!

Php 7 and MySql error when I try to select record from table [closed]

Hi have a strange problem with PHP and MySql connection.
I m using PHP 7.1.2 and MySql v5.5.64

Now I write the following code:

<?php
$mysqli = new mysqli("localhost", "usr_gest", "qo2f", "db_gest");
if ($mysqli->connect_errno) {
echo "Connessione a MySQL fallita: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
echo $mysqli->host_info . "n";

$mysqli = new mysqli("localhost", "usr_gest", "qo2f", "db_gest", 3306);
if ($mysqli->connect_errno) {
echo "Connessione a MySQL2 fallita: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
echo $mysqli->host_info . "n";

$sql = "SELECT * FROM login";
if ($mysqli->query($sql) === TRUE) { 
        echo "success";
} else {
        echo "Error creating table: " . $mysqli->error; 
}
$sql = "SELECT * FROM login;";
if ($mysqli->query($sql) === TRUE) { 
        echo "success";
} else {
        echo "Error creating table: " . $mysqli->error; 
}
$mysqli->close();
?>

If I try to open the page with this code I can see this:

Localhost via UNIX socket 
Localhost via UNIX socket 
Error select table1: 
Error select table2:

How can I fixed this error?

In my mysql database there is “login” table

Customizing woocommerce New Order email subject with product name, customer first name, last name and email address

I need to customize woocommerce New Order email subject with product name, customer first name, last name and email address.

I’ve tried to put {item_names} – {customer_first_name} {customer_last_name} – {customer_email} in the subject of New Order email but it doesn’t work.

So I’d like to see in New Order subject something like this:
[Site name] New Order #00000 – Product name – Joh Doe – [email protected]

Any help?

Thanks in advance

Marco

Flutter – cannot send data to PHP page thorugh HTTP POST request [duplicate]

I’ve recently started to use Flutter in order to develop Android apps.
Uselessly difficult and counter-intuitive, but I expected that having already developed under Android environment in the past (with Android Studio).

Anyway, I’m trying to make a simple POST request to a PHP page and retrieve the data.
The client-side is the following:

Future<User> createUser(String name, int id) async {
    
    // perform await (asynchronous) of a POST request, passing data in the body
    final response = await http.post(
      Uri.parse('http://MY_SERVER/json-encode.php'),
      headers: {"content-type": "application/json"},
      body: json.encode({
        'id' : id,
        'name' : name
      }),
    );

    // if the server returned 200 OK
    if (response.statusCode == 200) {

      // rest of the code
    }
  }

I call the method with a button

ElevatedButton(
    onPressed: () {
        createUser(_controller.text, 0);
    },
    child: const Text('Search user'),
),

The server-side (PHP page) is the following:

<?php

$data = array("id" => isset($_POST['id']) ? $_POST['id'] : -1, "name" => isset($_POST['name']) ? $_POST['name'] : 'NOT RECEIVED');

// return the same JSON data as confirmation, 
// or fixed data if something was not received correctly
echo json_encode($data);
exit();
?>

the client receives the data back from the PHP page, but does not send POST data (i receive -1 as ID and ‘NOT RECEIVED’ as name)

I also tried to add

header("Content-Type: application/json");

in the PHP page, but nothing changes.

For what absurd reason this (should be) simple code does not work as intended?

Thanks.

fetching multiple entity associations without Ramsey Doctrine uuid

I am using right now Symfony and Ramsey to generate mysql binary uuids and everything is working perfectly, both storage and data recovering. I want to decouple from this
library and generate my own database ids. I have created a custom class (CustomBinaryUuid) that generates Uuids from ramsey’s php uuid package (ramsey/uuid) and
converted to binary ($uuid->toBytes()). Ids are generated and stored properly.

The problem comes when recovering some data. I have three entities: user, group and comment. Groups have owner users and joined users (through pivot table). Comments belong to users and groups.
When I load the data from the User entity (their owned groups, joined groups and comments) with Ramsey it is able to recover ALL the information properly. But when trying to do the same using CustomBinaryUuid
and getting the data from the PersistentCollections with this code:

$ownedGroups = $entityItem->getOwnedGroups()->getValues();
$joinedGroups = $entityItem->getJoinedGroups()->getValues();
$comments = $entityItem->getComments()->getValues();

it doesn’t fetch “comments”. If I execute the following code just moving “comments” to the first position, only comments are recovered, ownedGroups and joinedGroups are empty.

$comments = $entityItem->getComments()->getValues();
$ownedGroups = $entityItem->getOwnedGroups()->getValues();
$joinedGroups = $entityItem->getJoinedGroups()->getValues();

With Ramsey, on both cases, all the data from all entities is recovered properly.

The only change I do from Ramsey to CustomBinaryUuid is on the Entities orm xml:

<!-- Ramsey -->        
<id name="id" type="uuid_binary" column="id">
    <generator strategy="CUSTOM"/>
    <custom-id-generator class="RamseyUuidDoctrineUuidV7Generator"/>
</id>
<!-- CustomBinaryUuid -->
<id name="id" type="binary" column="id" />

I have noticed that if I change just one entity id to CustomBinaryUuid, only this entity doesn’t recover all the information, the other entities using Ramsey get everything.

This is the CustomBinaryUuid class:

class CustomBinaryUuid
{
    public function __construct(private $uuid) {}

    public static function random(): self
    {
        $factory = new UuidFactory;
        $factory->setRandomGenerator(new CombGenerator(
            $factory->getRandomGenerator(),
            $factory->getNumberConverter()
        ));
        $factory->setCodec(new GuidStringCodec(
            $factory->getUuidBuilder()
        ));

        return new self($factory->uuid7());
    }

    public static function fromString(string $uuid): self
    {
        $factory = new UuidFactory;
        $uuidElement = $factory->fromString($uuid);
        return new self($uuidElement);
    }

    public function toBinary()
    {
        return $this->uuid->getBytes();
    }

    public function toString(): string
    {
        return $this->uuid->toString();
    }

}

I have been digging into Ramsey documentation and code with no luck of finding what is special on it.

What am I missing?

Thanks you.