Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/267.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP未获取数据,但正在生成表_Php_Minecraft - Fatal编程技术网

PHP未获取数据,但正在生成表

PHP未获取数据,但正在生成表,php,minecraft,Php,Minecraft,我需要它做的是去我的数据库,获取我在那里的数据。虽然它不起作用。我得到一张表格,里面没有数据!它仍然会生成新表,因为添加了更多的数据,而不是添加数据。以下是我的php: <?php mysql_connect("localhost", "", "") or die(mysql_error()); mysql_select_db("tcordero_playtime") or die(mysql_error()); $query = mysql_query("SELE

我需要它做的是去我的数据库,获取我在那里的数据。虽然它不起作用。我得到一张表格,里面没有数据!它仍然会生成新表,因为添加了更多的数据,而不是添加数据。以下是我的php:

 <?php 

 mysql_connect("localhost", "", "")

 or die(mysql_error()); 

 mysql_select_db("tcordero_playtime") or die(mysql_error()); 

 $query = mysql_query("SELECT * FROM players") 

 or die(mysql_error()); 
if (mysql_num_rows($query) == 0) {
    echo "No player information has been entered yet!";
}
else {
 Print "<table border cellpadding=1>"; 

 while($row = mysql_fetch_array( $query )) 

 { 

 Print "<tr>"; 

 Print "<th>Playername:</th> <td>".$query['playerName'] . "</td> "; 

 Print "<th>Total playtime:</th> <td>".$query['playtime' / 1000 / 60] . "</td> ";

 } 

 Print "</table>"; 
}
 ?>

数据库中的时间也以毫秒为单位。我如何让它们在几分钟甚至几小时内显示出来?
下面是一个页面示例以及出现的问题:

它应该是
$row['playerName']
等,而不是
$query['playerName']
。打开错误日志记录,它应该更加明显。

将此行中的$query更改为$row:

以前

Print "<th>Playername:</th> <td>".$query['playerName'] . "</td> "; 

Print "<th>Total playtime:</th> <td>".$query['playtime' / 1000 / 60] . "</td> ";
Print“Playername:”.$query['Playername']。" "; 
打印“总播放时间:”.$query['playtime'/1000/60]。" ";
之后

打印“Playername:.$row['Playername']。" "; 
打印“总播放时间:.”行['playtime'/1000/60]。" ";

您必须使用
$row['playerName']
而不是
$query['playerName']

您正在检索$row的值,因此应使用$row来获取值


另外,应关闭
。代码中的
未关闭。

您可以这样更改代码

Playername:“.$row['Playername']”

打印“总播放时间:.$row['playtime'/1000/60]”


这里似乎有不止一个问题。可以指出一个特定的问题,并且错误与该问题相关。
Print "<th>Playername:</th> <td>".$row['playerName'] . "</td> "; 

Print "<th>Total playtime:</th> <td>".$row['playtime' / 1000 / 60] . "</td> ";