编程perl语言,详细解释一下下面的代码,我想把下面的代码转换成php

#!/usr/bin/perl#TheSQLdatabaseneedstohaveatablecalledhighscores#thatlookssomethinglik... #!/usr/bin/perl
# The SQL database needs to have a table called highscores
# that looks something like this:
#
# CREATE TABLE highscores (
# game varchar(255) NOT NULL,
# player varchar(255) NOT NULL,
# score integer NOT NULL# );
#use strict;use CGI;use DBI;
# Read form data etc.my $cgi = new CGI;
# The results from the high score script will be in plain textprint
$cgi->header("text/plain");
my $game = $cgi->param('game');
my $playerName = $cgi->param('playerName');
my $score = $cgi->param('score');
exit 0 unless $game;
# This parameter is required
# Connect to a databasemy
$dbh = DBI->connect( 'DBI:mysql:databasename', 'username', 'password' ) || die "Could not connect to database: $DBI::errstr";
# Insert the player score if there are anyif( $playerName && $score) {
$dbh->do( "insert into highscores (game, player, score) values(?,?,?)", undef, $game, $playerName, $score );
}
# Fetch the high scoresmy
$sth = $dbh->prepare( 'SELECT player, score FROM highscores WHERE game=? ORDER BY score desc LIMIT 10' );
$sth->execute($game);
while (my $r = $sth->fetchrow_arrayref) {
print join(':',@$r),"\n"
}
展开
 我来答
kallend
2012-11-26
知道答主
回答量:3
采纳率:0%
帮助的人:2.9万
展开全部
$connect=mysql_connect($host,$user,$password) || die "Could not connect to database:mysql_error";

mysql_select_db($db[,$connect]); ip,用户,密码,数据库名自己去填
$query="insert into highscores (game, player, score) values(?,?,?)";
mysql_query($query);
$query1="SELECT player, score FROM highscores WHERE game=? ORDER BY score desc LIMIT 10";
$result=mysql_fetch_array(mysql_query($query1),MYSQL_ASSOC);
mysql_close($connect);
for($key=0;$key<count($result);$key++){
echo $a[$key];}
wizarot
2012-11-26 · TA获得超过187个赞
知道小有建树答主
回答量:330
采纳率:100%
帮助的人:225万
展开全部
把这页转了恐怕也没什么用,因为它调用了非常多的函数和文件
转过来也运行不了.
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
郝建刚002
2012-11-27 · TA获得超过105个赞
知道答主
回答量:91
采纳率:0%
帮助的人:53.4万
展开全部
没看明白啊?大哥你教教我啊
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(1)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式