php/MySQLがどのような言語であるかという基本的なことは、当社ではサポートしておりません。まず最初に書籍やネット上のリソースで十分ご理解の上、ご使用を開始してくださいますよう、お願いいたします。
注)当社のphpはデフォルトでは、register_globals
= on に設定されています。これを、register_globals
= off で使用したい場合には、.htaccessファイルに下記のように記述して、テキストモードでサーバーにアップロードしてください。
php_flag register_globals off
phpの使用方法
phpは、スクリプトをhtmlと混在して直接記述できるすぐれた言語です。標準でご利用いただけます。
htmlに直接記述する(拡張子は.php)mod_phpとしての使い方と、cgi-binディレクトリでcgiとして使う方法があります。
以下の手順でご使用ください。
1.mod_phpとして、htmlと混在して直接記述する方法
2.cgi-binディレクトリでcgiとして使用する場合
注)cgi-bin以外のディレクトリでcgiとして使用する場合には、下記の記述をした、.htaccessファイルを設置する必要があります。これによりそのディレクトリでcgiが実行可能となります。この場合は、phpはcgiとして実行されますので、ファイルの一番上の行に、#!/usr/local/bin/php と記述する必要があります。
<Files *.php>
options execcgi
SetHandler cgi-script
</Files>
phpMyAdminの使用
MySQLデータベースアカウントを作成された後は、下記のURLで
phpMyAdmin を使用することができます。ご利用を希望のお客様は、データベース作成要請時に、「phpMyAdmin使用希望」とご連絡ください。当社で設定させていただきます。phpMyAdmin
自体のご利用方法は当社ではサポートいたしておりません。ヘルプメニュー、ネット上のフォーラム、書籍等をご利用ください。
設定後の phpMyAdmin へのアクセス方法
http://ドメイン名.com/MyAdmin/
ユーザー名:データベースのユーザー名
パスワード:データベースのパスワード
になります。
MySQLの使用方法
標準では設定されていません。ご利用ご希望のお客様は、下記情報をご連絡ください。
データベース名
ユーザー名
パスワード
いずれも英数8文字程度でご指定ください。+*=/'_"#$%&\@等の記号文字ならびに、ハイフン’−’は使用できません。
設定完了後は、以下の手順でご使用ください。
mysql バックアップスクリプト
mysql リストアスクリプト
simple perl DBI mysql 接続スクリプト
なお、php/MySQLの詳細サポートは行っておりません。書籍ならびにネット上には数多くのリソースがございますので、そちらをご活用ください。
参考サイト(日本語)-yahoo等の検索サイトで、php
mysqlをキーワードにして検索すれば、数多くのリソースが見つかります。
日本PHPユーザー会
PHP日本語ページ
レッツPHP!
日本MySQLユーザ会
MySQL講座 [SMART!]
参考サイト(英語)
perl DBI documentation
php web site
php MySQL documentation
MySQL web site
#!/usr/local/bin/perl
###############################################################################
#
# mysql_backup.pl
#
# replace <database name> <user name> and <password> with
the
# correct values
#
###############################################################################
$database="<database name>";
$user="<user name>";
$password="<password>";
system "/usr/local/mysql/bin/mysqldump --password=$password -u $user $database > $database.sql";
$|=1;
print "Content-type: text/html\n\n";
print "<TITLE> Backup of $database database complete</TITLE>\n";
print "<B>The database has been backed up to
$ENV{'DOCUMENT_ROOT'}/cgi-bin/$database.sql</B><HR>\n";
open SQL,"$database.sql";
while (<SQL>) {
print;
print "<BR>\n";
}
close SQL;
exit 1;
#!/usr/local/bin/perl
##############################################################################
#
# mysql_restore.pl
#
# replace <database name> <user name> and <password> with
the
# correct values. Make sure the correct name is in $updatefile
#
##############################################################################
$database="<database name>";
$user="<user name>";
$password="<password>";
$updatefile="$ENV{'DOCUMENT_ROOT'}/cgi-bin/restore.sql";
$command = "/usr/bin/cat $updatefile | /usr/local/mysql/bin/mysql -f --password=$password -u $user $database";
$|=1;
print "Content-type: text/html\n\n";
print "<TITLE> Update of $database database</TITLE>\n";
print "Output from: $command<br>\n";
print "<hr><pre>";
system "$command";
print "</pre><br>\n";
print "<HR><B>Done</b>\n";
exit 1;
#!/usr/local/bin/perl
###########################################################################
#
# mysql_connect.pl
#
# uses the perl DBI module
#
# replace <database name> <user name> and <password> with
the correct values
#
###########################################################################
#
# set output to unbuffered and print the correct content-type
#
$|=1;
print "Content-Type: text/html\n\n";
#
# we need to use the DBI module
#
use DBI;
#
# replace <database name> <user name> and <password> with
the correct values
# set up the variables to connect to the database
#
$user='<user name>';
$passwd='<password>';
$dbname='<database name>';
$dsn = "DBI:mysql:$dbname";
#
# this establishes the connection to the database and lets us know
if it worked
#
print "Attempting to connect to the database...<BR>";
$dbh = DBI->connect($dsn, $user, $passwd);
if ( !defined $dbh) {
print "Fatal Error!<BR>Could not connect to database.<BR>";
print "Database: $dbname<BR>";
print "User: $user<BR><HR>";
exit 1;
} else {
print "Successful connection to database: <B>$dsn</B><BR>\n";
}
#
# generate our SQL commmand
# any SQL command can go here (select, create, alter, etc)
# replace <table> with correct value
#
$command ="select * from <table>";
print "Command: $command<p>\n";
#
# create a statement handle and prepare to execute the SQL statement
#
$sth = $dbh->prepare($command);
if ( !defined $sth ) {
print "Can't create Statement Handle Object $dbh->errstr<BR>\n";
exit 1;
}
#
# execute the command
#
$rv = $sth->execute;
print "Return Code: <B>$rv</B>".$dbh->errstr." <BR><HR>\n";
exit;