Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php // Database connection $host = 'localhost'; $dbname = 'your_database_name'; $usernam..

Decoded Output download

<?php // Database connection $host = 'localhost'; $dbname = 'your_database_name'; $username = 'your_username'; $password = 'your_password'; try { $pdo = new PDO("mysql:host=$host;dbname=$dbname", $username, $password); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $e) { die("Could not connect to the database $dbname :" . $e->getMessage()); } // Query to get data from table $sql = "SELECT * FROM users"; $stmt = $pdo->prepare($sql); $stmt->execute(); $users = $stmt->fetchAll(PDO::FETCH_ASSOC); // File path for CSV file $csvFilePath = 'users.csv'; // Write data to CSV file $csvFile = fopen($csvFilePath, 'w'); if ($csvFile === false) { die('Could not open or create CSV file'); } // Write headers to CSV file $header = array_keys($users[0]); fputcsv($csvFile, $header); // Write data to CSV file foreach ($users as $user) { fputcsv($csvFile, $user); } fclose($csvFile); echo "CSV file successfully created at $csvFilePath"; ?>

Did this file decode correctly?

Original Code

<?php // Database connection $host = 'localhost'; $dbname = 'your_database_name'; $username = 'your_username'; $password = 'your_password'; try { $pdo = new PDO("mysql:host=$host;dbname=$dbname", $username, $password); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $e) { die("Could not connect to the database $dbname :" . $e->getMessage()); } // Query to get data from table $sql = "SELECT * FROM users"; $stmt = $pdo->prepare($sql); $stmt->execute(); $users = $stmt->fetchAll(PDO::FETCH_ASSOC); // File path for CSV file $csvFilePath = 'users.csv'; // Write data to CSV file $csvFile = fopen($csvFilePath, 'w'); if ($csvFile === false) { die('Could not open or create CSV file'); } // Write headers to CSV file $header = array_keys($users[0]); fputcsv($csvFile, $header); // Write data to CSV file foreach ($users as $user) { fputcsv($csvFile, $user); } fclose($csvFile); echo "CSV file successfully created at $csvFilePath"; ?>

Function Calls

None

Variables

None

Stats

MD5 2993ab083fc8e65251e47ce8f001a37b
Eval Count 0
Decode Time 53 ms