【问题标题】:Mysql_connect errorMysql_connect 错误
【发布时间】: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/>";

    }
?>

有什么建议吗?

【问题讨论】:

标签: php mysql database


【解决方案1】:

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

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

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

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

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

【讨论】:

  • 当我删除问题中的代码时,我有另一个代码行可以与同一用户正常工作。感谢 error_reporting 提示。它与登录、事件有关,尽管它有效,并感谢您的提醒。已经改变了:)
猜你喜欢
  • 2012-10-17
  • 1970-01-01
  • 2012-11-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-07-04
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多