Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Aug 2009
    Posts
    5
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Displaying variables problem

    Hi,
    I am having a problem displaying error message and other variables.
    I am using the isset function to assess whether a variable has a value - if it does then the variable is displayed.

    PHP Code:
    if (isset($_SESSION['SESS_TEAM_NUM'])){
                                $team_num=$_SESSION['SESS_TEAM_NUM'];?>
    <h5>Your team number is: </h5> <?php echo $team_num;
    }
    When this variable has a value it is not being displayed. Is there a setting (maybe in the php.ini file) which stops this displaying?
    The reason I think this maybe is the .ini file is that on one system I have the variable is being displayed but on another it is not.
    This is driving me mad so any help would be great...

  • #2
    Regular Coder
    Join Date
    Mar 2006
    Posts
    238
    Thanks
    3
    Thanked 37 Times in 37 Posts
    For displaying error messages, please add to the top of your script:
    PHP Code:
    error_reporting(E_ALL);
    ini_set('display_errors','1'); 
    If I have not understood your question correctly, could you explain a little bit more which is the problem please ...

    Edit: as to php.ini, both seetings culd be done there too:
    Code:
    error_reporting = E_ALL
    display_errors = On
    But please do not use anything like that at the Production environment. At the Production environment all errors should be hidden from users. To completely disable standard PHP error output you could do the following:
    PHP Code:
    error_reporting(0);
    ini_set('display_errors','0'); 
    Last edited by SKDevelopment; 09-06-2009 at 03:42 PM.

  • #3
    New to the CF scene
    Join Date
    Aug 2009
    Posts
    5
    Thanks
    2
    Thanked 0 Times in 0 Posts
    thanks for the reply SK..
    The problem is that the variables such as the $_SESSION['SESS_TEAM_NUM'] variable below are not being displayed when they are populated with a value.
    I have checked the temp session files and values are being created for these session variables but they are not being displayed when the isset function below is run...
    I don't think this is a problem with the code so I was wondering if there is anything else that would stop them being displayed..
    thanks again.

  • #4
    Regular Coder
    Join Date
    Mar 2006
    Posts
    238
    Thanks
    3
    Thanked 37 Times in 37 Posts
    It is a pleasure.

    Do you have session_start() at the top of each page which uses sessions ?

    If you populate the array $_SESSION at one page, which has session_start() at the top, but viewing it at the other page which does not have session_start() at the top, the session data at the 2nd page would not be available.

    Please notice that session_start() sends HTTP header (sends a session cookie via an HTTP header to be exact), so it must be called before any output is sent to the browser.
    Last edited by SKDevelopment; 09-06-2009 at 06:25 PM.

  • Users who have thanked SKDevelopment for this post:

    bigron (09-06-2009)

  • #5
    New to the CF scene
    Join Date
    Aug 2009
    Posts
    5
    Thanks
    2
    Thanked 0 Times in 0 Posts
    holy cow..
    I had deleted session_start() from the top of the code when deleting something else...
    never even thought of checking it so you've saved me from pulling my hair out..apologies for wasting your time on this..
    thanks for the quick replies..


  •  

    Posting Permissions

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