Skip to content

Instantly share code, notes, and snippets.

@phpfiddle
Created February 5, 2020 10:36
Show Gist options
  • Save phpfiddle/c8d12e1310c7d322581a6da1ba63605f to your computer and use it in GitHub Desktop.
Save phpfiddle/c8d12e1310c7d322581a6da1ba63605f to your computer and use it in GitHub Desktop.
[ Posted by Rosario Camaggio ] provaconnegit
<html>
<head>
<title>PHP pdo</title>
</head>
<body>
<?php
$user = 'KBFD9iLsqO';
$password = 'hpZrTdZJCp';
$db = 'KBFD9iLsqO';
$host = 'remotemysql.com';
$port = 3306;
$conn = new PDO("mysql:host=$host; dbname=$db; port=$port", $user, $password);
$result = [];
$stmt = $conn->query("SELECT * FROM usertab");
while($row = $stmt->fetch(PDO::FETCH_ASSOC)){
$result[] = $row;
}
echo json_encode($result);
?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment