コメント |
@DIV
<?
header( "Content-Type: text/html; Charset=utf-8" );
header( "pragma: no-cache" );
header( "Expires: Wed, 31 May 2000 14:59:58 GMT" );
header( "Cache-control: no-cache" );
foreach( $_GET as $Key => $Value ) {
$_GET[$Key] = str_replace("\\\\", "\\", $Value );
$_GET[$Key] = str_replace("\\'", "'", $_GET[$Key] );
$_GET[$Key] = str_replace("\\\"", "\"", $_GET[$Key] );
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>SQL実行結果</title>
</head>
<body style='white-space:pre;'>
<?
print $_GET['text'];
$Server = 'localhost';
$DbName = 'データーベース名';
$User = 'ユーザー';
$Password = 'パスワード';
// 接続
$Connect = @mysql_connect( $Server, $User, $Password );
if ( !$Connect ) {
print "接続エラーです";
exit();
}
// DB選択
mysql_select_db( $DbName, $Connect );
//mysql_set_charset("utf8", $Connect);
mysql_query("set names 'utf8'", $Connect);
// クエリ
$result = mysql_query($_GET['text'], $Connect);
if ( !$result ) {
print "\n";
print "<span style='color:#f00'>" . mysql_error() . "</span>";
}
// 列数
$nField = @mysql_num_fields( $result );
if ( $nField ) {
$nCount = 0;
print "<table style='border:solid 1px #000;border-collapse:collapse;'>\n";
while ($row = mysql_fetch_row($result)) {
print "<tr>\n";
print "\t<td style='border:solid 1px #000;padding:5px;'>" . ($nCount + 1) . "</TD>\n";
for( $i = 0; $i < $nField; $i++ ) {
print "\t<td style='border:solid 1px #000;padding:5px;'>{$row[$i]}</TD>\n";
}
print "</tr>\n";
$nCount++;
}
print "</table>";
}
// 接続解除
mysql_close($Connect);
?>
</body>
</html>
@END |