如果帐户类型x包含y?

时间:2012-11-01 15:28:58

标签: php sql

我正在尝试将一组用户Basic引导至一种类型的个人资料页mod_profile.php,将另一组用户upgraded引导至不同的个人资料页mod_account.php。到目前为止,我有这个,但它似乎有麻烦。当我打开mod_account.php关于它无法从mod_profile或其他个人资料页面重新声明某些功能时,我收到错误,但我不明白为什么,我只想要加载其中一个页面每个用户类型。

有人可以告诉我我做错了吗?

我的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;

            }

1 个答案:

答案 0 :(得分:0)

好的,所以你的问题是你在某个时候加载同一个文件两次并重新定义函数。 Php有一个解决方案:) http://php.net/manual/en/function.include-once.php

include_once "functions.php"

这意味着在加载任何页面时,只有在尚未加载的情况下才会加载functions.php。

请告诉我这是否可以解决您的问题。第二个代码块是什么文件?