Skip to content

Instantly share code, notes, and snippets.

@TheNilesh
Created March 26, 2018 04:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TheNilesh/94197acbf132e41f091da101a4b6db36 to your computer and use it in GitHub Desktop.
Save TheNilesh/94197acbf132e41f091da101a4b6db36 to your computer and use it in GitHub Desktop.
PHP file to execute everything
<?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