2014-01-17 29 views
0

所以我將一些MySQL行導入到表單中,但似乎存在問題,數據庫沒有連接,它沒有選擇數據庫,我在Constants.php中有我的數據庫連接參數,在網站的其他頁面中工作正常,並且命令中也沒有語法錯誤,請幫助我。謝謝!將MySQL行導入表

<?php 
    require_once 'classes/Membership.php'; 
    require_once 'includes/constants.php'; 
    $membership = New Membership(); 
    $membership->confirm_Member(); 
    $con = new mysqli(DB_SERVER, DB_USER, DB_PASSWORD, DB_NAME) or 
    die('Error connecting Database'); 
?> 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
    <head> 
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
     <link rel="stylesheet" type="text/css" href="css/style.css" /> 
     <title>Post Scores | Admin Panel D2C</title> 
     <style type="text/css"> 
     </style> 
    </head> 

    <body> 
     <div class="main_body"> 

     <table width="1029" border="0" cellpadding="0" class="score_table" > 
      <td width="131"> 
      <form align="center" action="update_team_database.php" method="post"> 
      <tr> 

      <td> Team: </td> 
      <td width="831"> 

      <?php 
       $result = mysql_query("select DISTINCT TeamName from team") or die(mysql_error()); 
       echo '<select name="teamname1"><OPTION>'; 
       echo "Select a team</OPTION>"; 
       while ($row = mysql_fetch_array($result)){ 
       $team1 = $row["TeamName"]; 
       echo "<OPTION value=\"$team1\">$team1</OPTION>";  
      } 
      echo '</SELECT>'; 
      ?></td> 

      </tr> 
      </form> 
     </table> 
    </body> 
</html> 
+0

mysqli或mysql? mysqli中的連接爲什麼? –

+2

首先確保你在這個文件中有正確的數據庫憑據(通過回顯它來檢查DB_NAME),你已經混合使用了mysqli和mysql。使用mysqli_query而不是mysql_query。 –

+0

確保沒有錯誤,請使用$ mysqli-> connect_errno知道 –

回答