2012-11-01 115 views
0

我試圖將一組用戶Basic指向一種類型的配置文件頁面mod_profile.php,另一組用戶upgraded指向不同的配置文件頁面mod_account.php。到目前爲止,我有這個,但似乎有麻煩。當我打開mod_account.php關於它無法從mod_profile或其他配置文件頁面重新聲明某些功能時,我收到錯誤,但我不明白爲什麼,我只希望爲每個用戶類型加載一個頁面。如果賬戶類型x包含y?

有人能告訴我我做錯了什麼嗎?

profile.php頁:

<?php 
    $page_title = "Profile"; 
    include('includes/header.php'); 
    include ('includes/mod_login/login_form2.php');  

    // GET PROFILE ID FROM URL 
    if (isset ($_GET['id'])) { 
     $profile_id = $_GET['id']; 
    } 
    ?> 

    <?php 
    $user_info_set = get_user_info(); 
    if (!$user = mysql_fetch_array($user_info_set)) { 
     include ('includes/mod_profile/mod_noprofile.php'); 
    } else if (!isset($profile_id)) { 
     include("includes/mod_profile/mod_noprofile.php"); 
    } 

    $profile_info_set = get_profile_info(); 
    while ($profile = mysql_fetch_array($profile_info_set)) 

    if (isset ($profile_id)) 
    if ($user['account_status'] == "Active") { 
     include("includes/mod_profile/mod_profile.php"); 
    } 

    $profile_info3_set = get_profile_info3(); 

    while ($profile = mysql_fetch_array($profile_info3_set)) 
     if (isset ($profile_id)) 
     if ($user['account_type'] == "Basic 

    ---------- 

    ") { 
     include("includes/mod_profile/mod_account.php"); 
    } 
    ?> 
    <script type="text/javascript" src="assets/js/jquery.prettyPhoto.js"></script> 
    <?php include('includes/footer.php');?> 

我定義的函數代碼:

// profile functions 
     function get_user_info() { 
      global $connection; 
      global $profile_id; 
      $query = "SELECT * 
         FROM ptb_users 
         WHERE id = \"$profile_id\" 
         AND account_status = \"Active\" "; 
      $user_info_set = mysql_query($query, $connection); 
      confirm_query($user_info_set); 
      return $user_info_set; 
     } 

function get_profile_info() { 
      global $connection; 
      global $profile_id; 
      $query = "SELECT * 
         FROM ptb_profiles, ptb_users 
         WHERE ptb_profiles.user_id = \"$profile_id\" 
         AND account_type = \"Basic\" 
         AND ptb_profiles.user_id = ptb_users.id"; 
      $profile_info_set = mysql_query($query, $connection); 
      confirm_query($profile_info_set); 
      return $profile_info_set; 

      } 


      function get_profile_info3() { 
      global $connection; 
      global $profile_id; 
      $query = "SELECT * 
         FROM ptb_profiles, ptb_users 
         WHERE ptb_profiles.user_id = \"$profile_id\" 
         AND account_type = \"Upgraded\" 
         AND ptb_profiles.user_id = ptb_users.id"; 
      $profile_info3_set = mysql_query($query, $connection); 
      confirm_query($profile_info3_set); 
      return $profile_info3_set; 

      } 

回答

0

好了,你的問題是,你在某些時候加載同一個文件並重新定義功能。 PHP提供了一個解決方案,這個:) http://php.net/manual/en/function.include-once.php

include_once "functions.php" 

這意味着,在任何頁面的加載,將functions.php中只有當還沒有它已經加載。

讓我知道這是否解決您的問題。第二塊代碼是什麼文件?