Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?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);
- ?>
Add Comment
Please, Sign In to add comment