php – Não consigo aceder a uma base de dados que está online

Quero aceder a uma base de dados que está online, tenho o xampp e na pasta htdocs criei um ficheiro .php com o código abaixo para aceder (Os dados sensíveis foram trocados por “TESTE” para não serem partilhados). Quando faço localhost/nomeDoFicheiro no browser aparece-me “The requested URL was not found on this server”. O que poderei estar a fazer mal? Obrigado


<?php
    
    $dsn = "mysql:host=TESTE;dbname=TESTE";
    $user = "TESTE";
    $passwd = "TESTE";

    try
    {
        $pdo = new PDO($dsn, $user, $passwd);
        $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        echo "TESTE";
    }
    catch (PDOException $error)
    {
        echo $error->getMessage();
    }
    
    ?>

php – ERROR AL ENVIAR IMAGENES REDIMENSIONADAS A BASE DE DATOS CON $imagen_original = imagecreatefromjpeg($ruta);

la verdad soy novato tratando de supera este reto y aprender mucho mas de php.
el asunto estoy tratando de resolver un problema al cargar las imágenes de mi proyecto de inmobiliaria cuando las cargo al formulario y le doy subir imágenes me esta generando el siguiente error:
Fatal error:

Uncaught Error: Call to undefined function imagecreatefrompng() in C:xampp3htdocsportalhomeadminpropiedadesup_principal.php:25 Stack trace: #0 {main} thrown in C:xampp3htdocsportalhomeadminpropiedadesup_principal.php on line 25

y mi código para esta acción es el siguiente:

include '../conexion/conexion.php';
if ($_SERVER('REQUEST_METHOD') == 'POST') {
  $id = htmlentities($_POST('id'));
  $cont=0;
foreach ($_FILES('ruta')('tmp_name') as $key => $value) {
  $ruta = $_FILES('ruta')('tmp_name')($key);
  $imagen = $_FILES('ruta')('name')($key);

  $ancho = 500;
  $alto= 400;
  $info = pathinfo($imagen);
  $tamano = getimagesize($ruta);
  $width= $tamano(0);
  $height = $tamano(1);


  if ($info('extension') == 'jpg' || $info('extension') == 'JPG' ) {
    $imagen_original = imagecreatefromjpeg($ruta);
    $nueva = imagecreatetruecolor($ancho,$alto);
    imagecopyresampled($nueva, $imagen_original, 0,0,0,0, $ancho,$alto,$width,$height);
    $cont++;
    $ran = rand(000,999);
    $renombrar = $id.$ran.$cont;
    $copia = "inmuebles/".$renombrar.".jpg";
    imagejpeg($nueva,$copia);
  }elseif ($info('extension') == 'png' || $info('extension') == 'PNG' ) {
    $imagen_original = imagecreatefrompng($ruta);
    $nueva = imagecreatetruecolor($ancho,$alto);
    imagecopyresampled($nueva, $imagen_original, 0,0,0,0, $ancho,$alto,$width,$height);
    $cont++;
    $ran = rand(000,999);
    $renombrar = $id.$ran.$cont;
    $copia = "inmuebles/".$renombrar.".png";
    imagepng($nueva,$copia);
  }else {
    header('location:../extend/alerta.php?msj=Solo se admiten los formatos de imágen jpg y png&c=prop&p=img&t=error&id='.$id.'');
    exit;
  }

  $ins = $con->prepare("INSERT INTO imagenes VALUES(?,?,?) ");
  $ins->bind_param("iss",$id_img, $id, $copia);
  $id_img = '';
  $ins->execute();


}// termina foreach

if ($ins) {
  header('location:../extend/alerta.php?msj=Sus imágenes han sido cargadas con exito!&c=prop&p=img&t=success&id='.$id.'');
}else {
  header('location:../extend/alerta.php?msj=Sus imágenes no pudieron ser cargadas&c=prop&p=img&t=error&id='.$id.'');
}

  $ins->close();
  $con->close();
  }else {
    header('location:../extend/alerta.php?msj=Utiliza el formulario&c=prop&p=img&t=error&id='.$id.'');
  }

 ?>

Mi pregunta si alguien me puede ayudar con la solución o decir que otra alternativa puedo usar para esta función.. muchas gracias

7 – China Fast Color Base factory

Items: FAST GARNET GBC BASE
Alias:O-AMINOAZOTOLUENE
C.I.:37210
CAS:35472-85-6
Chemical Formula锛欳14H16ClN3
Appearance: Yellow brown powder
Free amine melting point 100鈩?/p>
Strength:100卤3%
Purity:鈮?0%
Uses: It mainly used for cotton fabric dyeing and printing, also can be used for dyeing viscose, silk, cotton fiber fabric. Can be used as dyes, organic pigments and pharmaceutical intermediates. Staining, AS-D, AS, AS-BS and naphthol red dye coupling. This product coupling ability is strong, coupling speed is slow, coupling pH value is 4-5.5China Fast Color Base factory
website:http://www.naphtholas.com/pigment-intermediates/fast-color-base/

entities – OO way of adding base field definitions

Without using any hook, it’s not possible, since to change the class used for an entity, it’s necessary to implement hook_entity_type_alter(), which is problematic to implement when more modules need to alter the entity definition.

Imagine two different modules that try to change the class used to implement the same entity.
For example, the first module could use the following code.

/**
 * Implements hook_entity_type_alter().
 */
function login_id_entity_type_alter(array &$entity_types) {
  $entity_types('user')->setClass(LoginIdUser::class);
}
namespace Drupallogin_idEntity;

use DrupalCoreEntityEntityTypeInterface;
use DrupalCoreFieldBaseFieldDefinition;
use DrupaluserEntityUser;

class LoginIdUser extends User {

  /**
   * {@inheritdoc}
   */
  public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
    /** @var DrupalCoreFieldBaseFieldDefinition() $fields */
    $fields = parent::baseFieldDefinitions();

    $fields('login_id') = BaseFieldDefinition::create('string')
      ->setLabel(t('Login ID'))
      ->setDescription(t('The ID used for the login credentials.'))
      ->setRequired(TRUE)
      ->setConstraints((
        'LoginId' => (),
        'LoginIdUnique' => (),
    ));

    $fields('name')->getItemDefinition()
      ->setClass('\Drupal\login_id\LoginIdItem');

    return $fields;
  }

}

The second module could use the following code.

/**
 * Implements hook_entity_type_alter().
 */
function admin_email_entity_type_alter(array &$entity_types) {
  $entity_types('user')->setClass(AdminEmailUser::class);
}
namespace Drupaladmin_emailEntity;

use DrupalCoreEntityEntityTypeInterface;
use DrupalCoreFieldBaseFieldDefinition;
use DrupaluserEntityUser;

class AdminEmailUser extends User {

  /**
   * {@inheritdoc}
   */
  public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
    /** @var DrupalCoreFieldBaseFieldDefinition() $fields */
    $fields = parent::baseFieldDefinitions();

    $fields('admin_mail') = BaseFieldDefinition::create('email')
      ->setLabel(t('Admin email'))
      ->setDescription(t('The email used from administrator users to contact the user.'))
      ->setDefaultValue('')
      ->addConstraint('UserMailUnique')
      ->addConstraint('UserMailRequired')
      ->addConstraint('ProtectedUserField');

    return $fields;
  }

}

With two modules implementing that code, only a field would be added to the entity. To get both the entity fields, LoginIdUser should extend AdminEmailUser, which would mean that a module should have the other one as dependency. (This assumes that admin_email_entity_type_alter() is executed before login_id_entity_type_alter(), which is what normally happens when the hook execution order isn’t altered by a hook_module_implements_alter() implementation, or when the weight associated to module isn’t altered by a call to module_set_weight().)

Implementing hook_entity_base_field_info() allows to modules to add different fields without interfering with each other.

As side note, hooks can be placed in a file different from a .module file, which is automatically loaded from Drupal. Which files are loaded from Drupal when looking for hooks is influenced by hook_hook_info(). With the implementations of that hook done from Drupal core modules, the files Drupal core looks for are the following.

  • <module_name>.tokens.inc
  • <module_name>.views.inc

If you are interested in reducing the size of the .module file, implementing hook_hook_info() to tell Drupal where your module hooks are could be a way to achieve it.