我对编码很陌生,几个月前就开始尝试了,然后这周又开始了。我以前在旧主机上工作的代码现在似乎不适用于所有未填充的 mySQL 信息!该页面连接到服务器,因为我尝试在它拾取的连接中放置错误,但我无法获取任何内容以获取行数或填充我的下拉框。我在下面粘贴了我的代码,所以你可以看到任何明显的错误。我的其他代码似乎可以毫无问题地写入表格。
谢谢,
克里斯
<html>
<head>
<title>Create a new team</title>
</head>
<body>
<form action="cteam.php" method="post">
<?php
$dbserver='localhost';
$dbusername='******';
$dbpassword='******';
$dbname='*******';
$con = mysql_connect("$dbserver","$dbusername","$dbpassword");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$result = mysql_query("select count(1) FROM Name");
$row = mysql_fetch_array($result);
$total1 = $row[0];
echo "Current No. of registered Teams: " . $total1;
mysql_close($con);
?>
<br>
Team Full Name: <input type="text" name="longname">
<br>
Team Short Name: <input type="text" name="shortname">
<br>
Link to Logo: <input type="text" name="logo">
<br>
Select Rink or Press Create new Venue link:
<br>
<?php
$query = "SELECT * FROM Rink";
$result = mysql_query($query);
?>
<select name="venue">
<?php
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
?>
<option value="<?php echo $line['Name'];?>"> <?php echo $line['Name'];?> </option>
<?php
}
?>
</select> <a href="http://beerleague.co.uk/pics/cvenue1.html">Create New Venue!</a>
<br>
Website address: <input type="text" name="website">
<br>
Twitter: <input type="text" name="twitter">
<br>
Facebook: <input type="text" name="facebook">
<br>
Link to image of home shirt: <input type="text" name="home_shirt">
<br>
Link to image of away shirt: <input type="text" name="away_shirt">
<br>
Link to image of Alt shirt: <input type="text" name=alt_shirt">
<br>
Team Bio: <input type="text" name="blurb">
<br>
<input type="submit">
</form>
</body>
</html>