【发布时间】:2016-04-11 22:38:23
【问题描述】:
在将数据库(我知道数据库不是问题)从一台服务器移动到另一台服务器后,我的 mysql-connect 代码出现问题:
<?php
mysql_connect("host", "username", "password") or die(mysql_error());
mysql_select_db("database") or die(mysql_error());
$query = "select COUNT(Motstander), ROUND(AVG(Serveess),2),ROUND(AVG(Dobbeltfeil),2), ROUND(AVG(1serveinn),2), ROUND(AVG(1servevinn),2), ROUND(AVG(2serveinn),2), ROUND(AVG(2servevinn),2), ROUND(AVG(Servicegamevinn),2), ROUND(AVG(Breakpointsvinn),2), ROUND(AVG(Lengde),2) from Statistikk where Navn='Melanie Stokke'";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)){
echo $row['COUNT(Motstander)']. " kamper fra 4. april 2016):</b> <br/>". "Serveess: ". $row['ROUND(AVG(Serveess),2)']. "<br/>Dobbeltfeil: ". $row['ROUND(AVG(Dobbeltfeil),2)']. "<br/>". "1. serve inne: ". $row['ROUND(AVG(1serveinn),2)']. "% ". "<br/>1. serve seiersprosent: ". $row['ROUND(AVG(1servevinn),2)']. "% ". "<br/>2. serve inne: ". $row['ROUND(AVG(2serveinn),2)']. "%". "<br/>2. serve seiersprosent: ". $row['ROUND(AVG(2servevinn),2)']. "%". "<br/>Servicegame seiersprosent: ". $row['ROUND(AVG(Servicegamevinn),2)']. "%". "<br/>Antall breakpoints: ". $row['ROUND(AVG(Breakpointsvinn),2)']. "<br/>Lengde: ". $row['ROUND(AVG(Lengde),2)']. " min. <br/>";
}
?>
它在http://www.tennis-norge.com/resultateter-melanie-stokke/ 工作,但在http://wwww.oddseren.com/stokkeres 工作,使用此代码:
<?php
mysql_connect("host", "user", "pass") or die(mysql_error());
mysql_select_db("database") or die(mysql_error());
$query = "select COUNT(Motstander), ROUND(AVG(Serveess),2),ROUND(AVG(Dobbeltfeil),2), ROUND(AVG(1serveinn),2), ROUND(AVG(1servevinn),2), ROUND(AVG(2serveinn),2), ROUND(AVG(2servevinn),2), ROUND(AVG(Servicegamevinn),2), ROUND(AVG(Breakpointsvinn),2), ROUND(AVG(Lengde),2) from Statistikk where Navn='Melanie Stokke'";
$result = mysql_query($query) or die(mysql_error());
round($query, 0);
while($row = mysql_fetch_array($result)){
echo $row['COUNT(Motstander)']. " kamper fra 4. april 2016):</b> <br/>". "Serveess: ". $row['ROUND(AVG(Serveess),2)']. "<br/>Dobbeltfeil: ". $row['ROUND(AVG(Dobbeltfeil),2)']. "<br/>". "1. serve inne: ". $row['ROUND(AVG(1serveinn),2)']. "% ". "<br/>1. serve seiersprosent: ". $row['ROUND(AVG(1servevinn),2)']. "% ". "<br/>2. serve inne: ". $row['ROUND(AVG(2serveinn),2)']. "%". "<br/>2. serve seiersprosent: ". $row['ROUND(AVG(2servevinn),2)']. "%". "<br/>Servicegame seiersprosent: ". $row['ROUND(AVG(Servicegamevinn),2)']. "%". "<br/>Antall breakpoints: ". $row['ROUND(AVG(Breakpointsvinn),2)']. "<br/>Lengde: ". $row['ROUND(AVG(Lengde),2)']. " min. <br/>";
}
?>
有什么建议吗?
【问题讨论】:
-
建议1,停止使用后期版本的php MySQL库中弃用和移除的
-
@Dagon 我尝试了其他连接,但没有任何运气。