首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >所需文件出现异常致命错误

所需文件出现异常致命错误
EN

Stack Overflow用户
提问于 2012-08-20 15:10:34
回答 2查看 105关注 0票数 0

我正在尝试设计一个带有下拉框的注册页面。这需要2个数据库连接,一个在点击注册按钮时将数据发送到数据库,另一个从数据库中提取信息以填充下拉框。直到几天前,我上传了一个与其他文件没有任何关系的文件,而只是为了获得config.inc.php (用于数据库连接和错误处理)的require语句,我才让这个脚本完美地工作。这个文件几乎在我的所有脚本中使用,并且在我的网站中除了少数脚本之外的所有脚本上都工作得很好。上传此文件后,我的注册摘要的部分将填充下拉框不再有效。

下面是有问题的片段(我省略了数据验证,如果需要,我可以重新添加大多数html部分)。

代码语言:javascript
运行
复制
<?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&nbsp;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的第56行的/home5/virtua15/public_html/gatewayaviation/includes/config.inc.php:36)中声明

EN

回答 2

Stack Overflow用户

发布于 2012-08-20 15:12:08

你应该有

代码语言:javascript
运行
复制
require_once('includes/config.inc.php');
require_once(MYSQL);

但是为什么需要配置和MYSQL两次呢?一旦它对整个脚本来说足够了,如果您从任何IF语句开始,它就可以对它们起作用。

票数 0
EN

Stack Overflow用户

发布于 2012-08-20 15:24:11

使用

require_once('includes/config.inc.php');

并删除第二个require('includes/config.inc.php');实例。

保持连接打开,并仅在脚本结束时将其关闭。而是在使用mysqli_free_result($result);从数据库中提取数据后处理结果

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12033538

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档