我正在尝试设计一个带有下拉框的注册页面。这需要 2 个数据库连接,一个在点击注册按钮时将数据发送到数据库,另一个从数据库中提取信息以填充下拉框。直到几天前,当我上传了一个与其他文件无关的文件时,我让这个脚本完美无缺,除了一个 require 语句来获取 config.inc.php (用于数据库连接和错误处理目的。)这个文件是几乎在我所有的脚本中都使用过,并且在我的网站中除了少数脚本之外的所有脚本都可以正常工作。上传此文件后,我的注册脚本部分填充下拉框不再起作用。
下面是有问题的脚本(我省略了数据验证和大部分 html 部分,如果需要,我可以重新添加它们。)
<?php
require_once('includes/config.inc.php');
$page_title = 'Register';
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
require_once(MYSQL);
$trimmed = array_map('trim', $_POST);
$fn = $ln = $usr = $pw = $bd = $gs = $bs = FALSE;
//DATA VALIDATION
//END DATA VALIDATION
if($fn && $ln && $usr && $e && $pw && $bd && $gs && $bs) {
$q = "SELECT user_id FROM Users WHERE email='$e'";
$r = mysqli_query ($dbc, $q) or trigger_error("Query: $q\n<br/>MySQL Error: " . mysqli_error($dbc));
if (mysqli_num_rows($r) == 0) {
$a = md5(uniqid(rand(), true));
$q = "INSERT INTO Users (first_name, last_name, user_name, email, password1, birthdate, gamespy_id, base, active, registration_date) VALUES ('$fn', '$ln', '$usr', '$e', SHA1('$pw'), '$bd', '$gs', '$bs', '$a', NOW() )";
$r = mysqli_query($dbc, $q) or trigger_error("Query: $q\n <br/>MySQL Error:" . mysqli_error($dbc));
if (mysqli_affected_rows($dbc) == 1){
$body = "Thank you for registering with Gateway Aviation. To activate your account, please click on this link:\n\n";
$body .= BASE_URL . 'activate.php?x=' . urlencode($e) . "&y=$a";
mail($trimmed['email'],'Registration Confirmation', $body, 'From: noreply@virtual-aviation.org');
echo '<h3> Thank you for registering! A confirmation email has been sent to your address. Please click on the link in that email in order to activeate your accout.</h3>';
exit();
} else {
echo '<p class="error>You could not be registered due to a system error. We apologize for any inconvenience.</p>';
}
} else {
echo '<p class="error"> That email has already been registered. If you have forgotten your password, use the link to reset it.</p>';
}
} else {
echo '<p class="error">Please try again</p>';
}
}
?>
<td><input type='text' name='gamespyid' value='<?php if(isset($trimmed['gamespyid'])) echo $trimmed['gamespyid'];?>'/></td>
</tr>
<td>Base:</td>
<td><select name="base" size="1">
<option>
Select One
</option>
<?php
require_once(MYSQL);
$q = "SELECT airport_id, CONCAT_WS(' ', airport_code,' - ' airport_name) FROM airports ORDER BY airport_code ASC";
$r = mysqli_query ($dbc, $q);
if (mysqli_num_rows($r) > 0) {
while ($row = mysqli_fetch_array ($r, MYSQLI_NUM)) {
echo "<option value=\"$row[0]\"";
if (isset($_POST['existing']) && ($_POST['existing'] == $row[0]) ) echo 'selected="selected"'; echo ">$row[1]</option>\n";
}
} else {
echo '<option>Please a new airport first.</option>';
}
mysqli_free_result($result);
?>
</select></td>
</table>
<input type='submit' name='submit' value='Register'/>
</form>
</body>
</html>
我也在我的错误日志中收到此错误 [20-Aug-2012 03:09:25] PHP 致命错误:无法重新声明 my_error_handler() (之前在 /home5/virtua15/public_html/gatewayaviation/includes/config.inc.php 中声明:36) 在第 56 行的 /home5/virtua15/public_html/gatewayaviation/includes/config.inc.php