Created
December 2, 2018 10:22
-
-
Save arwankhoiruddin/62bb8b8d31ef1d1475aaa3ce4c7eaff0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// this is unsafe way to get JSON from your MySQL... but it is fun... hahaha | |
$servername = "myhost"; | |
$username = "myusername"; | |
$password = "mypassword"; | |
$dbname = "mydb"; | |
$sql = $_GET['sql']; | |
$con=mysqli_connect($servername, $username, $password, $dbname); | |
// Check connection | |
if (mysqli_connect_errno()) | |
{ | |
echo "Failed to connect to MySQL: " . mysqli_connect_error(); | |
} | |
$result=mysqli_query($con,$sql); | |
$arr = []; | |
while($row = mysqli_fetch_assoc($result)){ | |
foreach($row as $key => $value){ | |
$arr[$key] = $value; | |
} | |
} | |
echo json_encode($arr); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment