fixed db connection

This commit is contained in:
2026-09-10 10:28:24 +02:00
parent 62bfb4d77f
commit 88c454c5d4
4 changed files with 95 additions and 216 deletions
+15 -4
View File
@@ -1,8 +1,19 @@
<?php
$con = mysqli_connect('localhost', 'u00wiumd4xnrd', 'ukowysga7w5x', 'dbcov4clvrmrzn');␍
require_once __DIR__ . '/../vendor/autoload.php';
if (!isset($_ENV['DB_HOST'])) {
Dotenv\Dotenv::createImmutable(__DIR__ . '/../')->safeLoad();
}
$con = mysqli_connect(
$_ENV['DB_HOST'] ?? 'localhost',
$_ENV['DB_USERNAME'] ?? '',
$_ENV['DB_PASSWORD'] ?? '',
$_ENV['DB_DATABASE'] ?? ''
);
// Check connection
if (mysqli_connect_errno())␍
{␍
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
?>
+15 -3
View File
@@ -1,7 +1,19 @@
<?php
//dependent dropdown in php Database Connection
$conn = new mysqli('localhost', 'u00wiumd4xnrd', 'ukowysga7w5x', 'dbcov4clvrmrzn');␍
require_once __DIR__ . '/../vendor/autoload.php';
if (!isset($_ENV['DB_HOST'])) {
Dotenv\Dotenv::createImmutable(__DIR__ . '/../')->safeLoad();
}
$conn = new mysqli(
$_ENV['DB_HOST'] ?? 'localhost',
$_ENV['DB_USERNAME'] ?? '',
$_ENV['DB_PASSWORD'] ?? '',
$_ENV['DB_DATABASE'] ?? ''
);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);␍
die("Connection failed: " . $conn->connect_error);
}
?>
+14 -77
View File
@@ -1,18 +1,26 @@
<?php
require_once __DIR__ . '/../../vendor/autoload.php';
if (!isset($_ENV['DB_HOST'])) {
Dotenv\Dotenv::createImmutable(__DIR__ . '/../../')->safeLoad();
}
Class Dropdown
{
private $host = 'localhost';
private $username = 'u00wiumd4xnrd';
private $password = 'ukowysga7w5x';
private $dbname = 'dbcov4clvrmrzn';
private $host;
private $username;
private $password;
private $dbname;
private $connection;
//establish connection
public function __construct()
{
$this->host = $_ENV['DB_HOST'] ?? 'localhost';
$this->username = $_ENV['DB_USERNAME'] ?? '';
$this->password = $_ENV['DB_PASSWORD'] ?? '';
$this->dbname = $_ENV['DB_DATABASE'] ?? '';
try
{
@@ -23,74 +31,3 @@ Class Dropdown
echo "Connection error " . $e->getMessage();
}
}
//fetch all country records from database
public function fetchCountry()
{
$data = null;
$query = "SELECT * FROM article_type ORDER BY article_type.name_articletype";
if ($sql = $this->connection->query($query))
{
while ($rows = mysqli_fetch_assoc($sql))
{
$data[] = $rows;
}
}
return $data;
}
//fetch model records from database depend upon country id
public function fetchModel($idarticletype)
{
$data = null;
$query = "SELECT * FROM modelarticle WHERE idarticletype='".$idarticletype."' ";
if ($sql = $this->connection->query($query))
{
while ($rows = mysqli_fetch_assoc($sql))
{
$data[] = $rows;
}
}
return $data;
}
//fetch Charact records from database depend on article type
public function fetchCharact($idarticletype)
{
$data = null;
$idarticletype = (int)$idarticletype;
$query = "
SELECT DISTINCT
ac.*
FROM article_characteristic ac
INNER JOIN standards s
ON s.idarticlecharacteristic = ac.idarticlecharacteristic
AND s.idarticletype = ac.idarticletype
WHERE ac.idarticletype = $idarticletype
AND s.active = 'Y'
ORDER BY ac.name_articlecharacteristic
";
if ($sql = $this->connection->query($query))
{
while ($rows = mysqli_fetch_assoc($sql))
{
$data[] = $rows;
}
}
return $data;
}
}
?>
+11 -92
View File
@@ -1,121 +1,40 @@
␍
<?php
// dump db and backup folder yogasoul... placed into claudiosironi.com ... folder of backup = tempzip in the main ideezeur folder␍
// Archivia in ZIP la cartella modulo_certificazione (backup)
// NB: il vecchio blocco di dump database è stato rimosso perché conteneva
// credenziali in chiaro ed era disattivato. Se serve un dump DB,
// usare mysqldump o un comando artisan dedicato.
␍
//dump database ␍
/*␍
ini_set('memory_limit', '-1');␍
// Database configuration␍
$host = "localhost";␍
$username = "u00wiumd4xnrd";␍
$password = "ukowysga7w5x";␍
$database_name = "dbcov4clvrmrzn";␍
␍
// Get connection object and set the charset␍
$conn = mysqli_connect($host, $username, $password, $database_name);␍
$conn->set_charset("utf8");␍
␍
␍
// Get All Table Names From the Database␍
$tables = array();␍
$sql = "SHOW TABLES";␍
$result = mysqli_query($conn, $sql);␍
␍
while ($row = mysqli_fetch_row($result)) {␍
$tables[] = $row[0];␍
}␍
?>␍
<?php␍
$sqlScript = "";␍
foreach ($tables as $table) {␍
␍
// Prepare SQLscript for creating table structure␍
$query = "SHOW CREATE TABLE $table";␍
$result = mysqli_query($conn, $query);␍
$row = mysqli_fetch_row($result);␍
␍
$sqlScript .= "\n\n" . $row[1] . ";\n\n";␍
␍
␍
$query = "SELECT * FROM $table";␍
$result = mysqli_query($conn, $query);␍
␍
$columnCount = mysqli_num_fields($result);␍
␍
// Prepare SQLscript for dumping data for each table␍
for ($i = 0; $i < $columnCount; $i ++) {␍
while ($row = mysqli_fetch_row($result)) {␍
$sqlScript .= "INSERT INTO $table VALUES(";␍
for ($j = 0; $j < $columnCount; $j ++) {␍
$row[$j] = $row[$j];␍
␍
if (isset($row[$j])) {␍
$sqlScript .= '"' . $row[$j] . '"';␍
} else {␍
$sqlScript .= '""';␍
}␍
if ($j < ($columnCount - 1)) {␍
$sqlScript .= ',';␍
}␍
}␍
$sqlScript .= ");\n";␍
}␍
}␍
␍
$sqlScript .= "\n"; ␍
}␍
?>␍
<?php␍
if(!empty($sqlScript))␍
{␍
// Save the SQL script to a backup file␍
$backup_file_name = '../tempbck/'.$database_name . '_backup_.sql';␍
$fileHandler = fopen($backup_file_name, 'w+');␍
$number_of_lines = fwrite($fileHandler, $sqlScript);␍
fclose($fileHandler); ␍
} */␍
?>␍
␍
<? ␍
// archive into ZIP the folder␍
ignore_user_abort(true);
set_time_limit(3600);
␍
$main_path = '../modulo_certificazione';
$zip_file = '../tempbck//cimac.tar';
if (file_exists($main_path) && is_dir($main_path)) ␍
{␍
if (file_exists($main_path) && is_dir($main_path)) {
$zip = new ZipArchive();
if (file_exists($zip_file)) {
unlink($zip_file); // truncate ZIP
}
if ($zip->open($zip_file, ZIPARCHIVE::CREATE)!==TRUE) {␍
if ($zip->open($zip_file, ZIPARCHIVE::CREATE) !== TRUE) {
die("cannot open <$zip_file>\n");
}
$files = 0;
$paths = array($main_path);
while (list(, $path) = each($paths))␍
{␍
foreach (glob($path.'/*') as $p)␍
{␍
while (list(, $path) = each($paths)) {
foreach (glob($path . '/*') as $p) {
if (is_dir($p)) {
$paths[] = $p;
} else {
$zip->addFile($p);
$files++;
␍
echo $p."<br>\n";␍
echo $p . "<br>\n";
}
}
}
echo 'Total files: '.$files;␍
␍
echo 'Total files: ' . $files;
$zip->close();
}
?>␍