Results 1 to 2 of 2

Thread: Another Variable Question *SOLVED*

  1. #1

    Thread Starter
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Another Variable Question *SOLVED*

    When a user logs in I get all their details using the below code.

    Each user has around 15/20 items that I want stored. Is there a way i can store the $check2 array() so I can simply use $check2[0], $check2[1] etc...in any other page/function i've got?

    or will I have to use the code below each time I want to display something about the user?

    PHP Code:
    function get_user_details() {

    $query ="Select * from user_details WHERE user_name = '$uname'";
    $check mysql_query($query);
    $check2 mysql_fetch_row($check);



    Last edited by lintz; Aug 28th, 2004 at 05:34 AM.

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906
    Store $check as a global array if you want to access it from aother function. Like this:
    PHP Code:
    $GLOBALS['check2'] = $check2
    You can then acces it in any other function using one of the following methods. Declare the variable as global at the beginning of the function:
    PHP Code:
    function myfunction() 
    {
        global 
    $check2;


    Or use the $GLOBALS array:
    PHP Code:
    function myfunction()
    {
        echo(
    $GLOBALS['check2'][0]);

    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width