所以我将一些 MySQL 行导入到表单中,但似乎有一个问题,数据库无法连接,它说没有选择数据库,我的数据库连接参数在 Constants.php 中,它们在另一个中工作正常网站页面,命令中也没有语法错误,请帮助我。谢谢!
<?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>
最佳答案
我建议您使用面向对象的方式使用MySQLi通过MySQL执行查询
您可以在这里查看示例 http://in2.php.net/manual/en/mysqli.query.php
由于 MySQL 从 PHP 5.5 开始已被弃用
关于php - 将 MySQL 行导入表中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21186272/