Startseite · Projekte · Kontakt · Impressum

Web-Kommandozeile für MySQL

<html>
<head>
<title>MySQL Query</title>
</head>
<body>
<form name="dump" action="" method="post">
<input type="text" name="hostname" value="<?php echo isset($_POST['hostname']) ? $_POST['hostname'] : ''?>" style="width:300px;" /> Hostname<br />
<input type="text" name="database" value="<?php echo isset($_POST['database']) ? $_POST['database'] : ''?>" style="width:300px;" /> Database<br />
<input type="text" name="username" value="<?php echo isset($_POST['username']) ? $_POST['username'] : ''?>" style="width:300px;" /> Username<br />
<input type="text" name="password" value="<?php echo isset($_POST['password']) ? $_POST['password'] : ''?>" style="width:300px;" /> Password<br />
<textarea name="query" style="width:300px;height:150px;"><?php echo isset($_POST['query']) ? stripslashes($_POST['query']) : ''?></textarea> Query<br />
<input type="submit" name="now" value="Query!" />
</form>

<?php

ini_set
('error_reporting'E_ALL);

$posted     false;
$connected  false;
$selected   false;
$message    '';


if (
sizeof($_POST) > 0) {
    
$posted true;
}

if (
$posted 
        
and @mysql_connect($_POST['hostname'], $_POST['username'], $_POST['password'])) {
    
$connected true;
} else {
    
$message mysql_error();
}

if (
$connected
        
and @mysql_select_db($_POST['database'])) {
    
$selected true;
} else {
    
$message mysql_error();
}

if (
$selected) {
    echo 
'<pre>';
    
$sql stripslashes($_POST['query']);
    if (
$result mysql_query($sql)) {
        
$message $sql;
        
        
$select strpos(strtolower($sql), 'select');
        
$show strpos(strtolower($sql), 'show');
        if (
$select !== false or $show !== false) {
            while (
$row mysql_fetch_array($resultMYSQL_NUM)) 
            {
                
$count count($row);
                for (
$i 0$i $count$i++)
                {
                    echo 
$row[$i] . ';';
                }
                echo 
"n";
            }
        }    
    } else {
        echo 
mysql_error();
    }
    echo 
'</pre>';
}

echo 
$message;

?>

</body>
</html>

Zurück

Vorherige: Promotion für Appointmind - Blogs
Nächste: Spamming mit contact.php und conlact.php

Kommentare (2)

Alternativ könnte man auch Adminer http://www.adminer.org/ nehmen. Besteht ebenfalls aus nur einer Datei und ist wesentlich komfortabler zu benutzen :-)
#1 - Leo - 22.01.2012 - 19:58
Danke für den Tipp
:-)
#2 - Ralf - 22.01.2012 - 20:19

Abonnieren Sie unseren Feed:   RSS Feed RSS Feed  Atom Feed Atom Feed

.