Last active
August 29, 2015 14:19
-
-
Save nkkarthik/5bedf8cbbc176194e4e0 to your computer and use it in GitHub Desktop.
php runs mssql query on command line and returns the results
This file contains 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 | |
$server = $_POST['server']; | |
$db = $_POST['db']; | |
$raw_query = $_POST['query']; | |
$trimmed_query = trim(preg_replace('/\s+/', ' ', $raw_query)); | |
$cmd = 'sqlcmd -S ' . $server . ' -d ' . $db . ' -Q "' . $trimmed_query . '"'; | |
echo shell_exec($cmd); | |
?> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment