Mysql_connect错误

时间:2016-04-11 22:38:24

标签: php mysql database

我将数据库(我知道数据库不是问题)从一台服务器移动到另一台服务器后,我的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 个答案:

答案 0 :(得分:0)

您可能在第二台服务器上没有用户tennis_norge_com

错误500可能是由于与mysql的连接错误造成的。

您可以在脚本开头添加更多信息。

error_reporting(E_ALL);
ini_set('display_errors', 1);

一个提示......在互联网上的公共帖子中提供登录/密码并不是一个好主意。