Created
March 26, 2018 04:40
-
-
Save TheNilesh/94197acbf132e41f091da101a4b6db36 to your computer and use it in GitHub Desktop.
PHP file to execute everything
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 | |
//Creating a connection | |
$dbname = $_GET["dbname"]; | |
$con = mysqli_connect("localhost:3306","root","",$dbname); | |
if (mysqli_connect_errno()) | |
{ | |
echo "Failed to connect to MySQL: " . mysqli_connect_error(); | |
} | |
/*get the sql query to execute*/ | |
$sql = $_GET["sql"]; | |
$result = mysqli_query($con ,$sql); | |
while ($row = mysqli_fetch_assoc($result)) { | |
$array[] = $row; | |
} | |
header('Content-Type:Application/json'); | |
echo json_encode($array); | |
mysqli_free_result($result); | |
mysqli_close($con); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment