Menu

Awkard install still not working...

Help
2003-02-18
2003-03-28
1 2 > >> (Page 1 of 2)
  • Nobody/Anonymous

    First off... props to the project, I've seen several shareware programs to do essentially this, but as I moved from org to org I wouldnt always be able to purchase a new license, so I wasnt able to really be able to use it (and couldnt always get my code snippets back out).

    Onto my problem... this is a fresh install of the latest version (currently .3) on a Win2K Pro PC with IIS 5, PHP 4.3.0, and MySQL 4.01.0 (Gamma).

    I am worried that this will end up being an rtfm question that I have somehow managed to miss after reading & rereading the README and INSTALL docs included in the tar download...

    So I created a virtual dir in IIS, created a DB & user with nearly all perms to that DB, adjusted the config.php file, but I am several repeats of essentially the same error message... "Undefined index: {various trailing text}".

    Now, I know I could probably go through each file, and debug it by hand, but is there some .sql script that I might be missing that i could use to setup the db's tables, or maybe a step I missed?

    Additionally, i now get an "Config valid" msg when I check the configuration.  It took awhile to get this message, the first time I tried the "Install" link, the first few tables seemed to be created fine, but the section that seemed to be updating tables from a previous version (that I dont think existed yet... since I started with v.3) choked... So I tried the v.2 upgrade, and now get the setup ok message.

    Regards,
    Tj

     
    • Brad Fears

      Brad Fears - 2003-02-18

      Sounds like a database problem of some nature.  Perhaps my setup is conflicting with your version of mysql...

      After running through the setup, can you take a look at your database schema to see if an index is defined for each table?

      Regarding the "check configuration" in setup, you should be able to run the fresh install straight through after you get a "Config valid" message, but if something is misconfigured prior to running the check for the first time, the results can be unpredictable.  A fresh install actually steps through the "upgrade" process as well as a new install process in the setup.php, but it shouldn't need to actually perform any steps other than the "new" stuff on a fresh install.

      --Brad Fears

       
    • Nobody/Anonymous

      I've got the following in MySQL...

      3 tables:
      * phpcc_categories (idx = "cid")
      * phpcc_snippets (idx = "sid")
      * phpcc_users (idx = "userid")

      And I've given the user every priv to the database to be used for the app.

      The errors during install seemed to be DB related (but they all appear to be ok now as I get "ok" msgs... but didnt initially).

      Here is an example of the errors that I am getting now...
      "Undefined index: isloggedin in C:\Inetpub\codebank\header.php on line 5"

      which refers to this line in the mentioned file...
      "if ($_SESSION['isloggedin'] == $glbl_hash) {..."

      I am not familiar with the session array... but this seems to be the issue (its referencing a item in the session array/has/etc that it is unable to find correct?)

      Tj

       
      • Brad Fears

        Brad Fears - 2003-02-19

        Do you have session support enabled in your php config?  You can either open the php.ini file to check or make a short php file that runs the "phpinfo()" function to check.

        It's not likely to be disabled, as it defaults to enabled.

        If it is enabled, try echoing your session variables to see if they exist.  You can do so by adding the following lines to header.php starting at line 4 (right after require_once...) :

        echo "Session: ".$_SESSION['isloggedin']."<br>";
        echo "Session: ".$_SESSION['username']."<br>";
        echo "Session: ".$_SESSION['userid']."<br>";
        echo "Session: ".$_SESSION['isadmin']."<br>";
        echo "Session: ".$_SESSION['user_theme']."<br>";

        If you're setup as an administrator, each variable should contain a value.  Don't post the output in your response, just make sure that each variable contains something.

        Another thing to try would be enabling "register_globals" in your php.ini, although phpCC will work without it by default.

        Let me know what you find.

        --Brad Fears

         
    • Nobody/Anonymous

      I've got the following in MySQL...

      3 tables:
      * phpcc_categories (idx = "cid")
      * phpcc_snippets (idx = "sid")
      * phpcc_users (idx = "userid")

      And I've given the user every priv to the database to be used for the app.

      The errors during install seemed to be DB related (but they all appear to be ok now as I get "ok" msgs... but didnt initially).

      Here is an example of the errors that I am getting now...
      "Undefined index: isloggedin in C:\Inetpub\codebank\header.php on line 5"

      which refers to this line in the mentioned file...
      "if ($_SESSION['isloggedin'] == $glbl_hash) {..."

      I am not familiar with the session array... but this seems to be the issue (its referencing a item in the session array/has/etc that it is unable to find correct?)

      Tj

       
    • Nobody/Anonymous

      I added the code to dump the values of SESSION, and refreshed... they are all blank (just says "SESSION: ").

      I also set register_globals on, and refreshed... no change (I checked phpinfo page to make sure they it did say that it was enabled, and it was... also re-checked to make sure sessions were enabled and they were).

      An additional note... I saw the security bulletin on PHP.net and upgraded to PHP 4.3.1 the other day, anyone know of any issues with 4.3.1 (the site claimed there were no other changes, so it should have a minimal impact).

      Regards,
      Tj

       
      • Doug Damon

        Doug Damon - 2003-02-19

        Set File_uploads = on in your php.ini.  I had the same problem here.

         
    • Brad Fears

      Brad Fears - 2003-02-19

      Does the 'Undefined index' error actually prevent you from seeing the page?  If not, what happens when you try to login?  Do you session echos register any values?

      --Brad Fears

       
    • Nobody/Anonymous

      doug_damon:
      I checked out the file_uploads setting, and it was reported as being enabled in the phpinfo page, I checked the ini to make sure and it is enabled there too (when you had the problem, did you find it was relavent to a particular version of PHP, or was it with any version of PHP with the CodeCab app?)

      brad_fears:
      You can see the output here if you want...
      http://www.geekcheck.net/~tjay/errors_screenshot_l.jpg (big pict)
      http://www.geekcheck.net/~tjay/errors_screenshot_s.jpg (smaller version of same pict)

      ...it, if nothing else, is annoying, and does appear to be breaking functionality.

      After I logged in, this is what I see...
      http://www.geekcheck.net/~tjay/errors_screenshot_\(after logging in).jpg 

      So it appears that the code is assuming the a session is in place, when no session is created until you log in? (does that sound correct, it appears to be... I logged out, and the multiple errors were listed again).

      Tj

       
    • Nobody/Anonymous

      Also, when logged in as admin, and going to the Category Admin page, I see this...

      Notice: Undefined index: submit in C:\Inetpub\codebank\category.php on line 42

      Notice: Undefined index: submit in C:\Inetpub\codebank\category.php on line 66

      Notice: Undefined index: del in C:\Inetpub\codebank\category.php on line 91

      Notice: Undefined index: cid in C:\Inetpub\codebank\category.php on line 111

      Notice: Undefined index: cid in C:\Inetpub\codebank\category.php on line 111

      Notice: Undefined index: tl in C:\Inetpub\codebank\category.php on line 111

      Notice: Undefined index: submit in C:\Inetpub\codebank\category.php on line 115

      Notice: Undefined variable: in_submit in C:\Inetpub\codebank\category.php on line 121

      Notice: Undefined index: cid in C:\Inetpub\codebank\category.php on line 207

      Notice: Undefined index: submit in C:\Inetpub\codebank\category.php on line 213

      Notice: Undefined index: category_id in C:\Inetpub\codebank\category.php on line 214

      Notice: Undefined index: submit in C:\Inetpub\codebank\category.php on line 311

      Notice: Undefined index: browse in C:\Inetpub\codebank\category.php on line 311

      Notice: Undefined index: sub in C:\Inetpub\codebank\category.php on line 311

      Notice: Undefined index: tl in C:\Inetpub\codebank\category.php on line 312

      Also, my file name for the 3rd pict link didnt seem to survive the post (i shouldnt have put spaces in the filename) if you cpy&pst from http all the way to the .jpg you can view the pict if you want.

      Tj

       
    • Brad Fears

      Brad Fears - 2003-02-21

      I spent an hour and a half tonight digging through old usenet postings, and found several curious references to this problem.  First of all, check out this url:

      http://bugs.php.net/bug.php?id=16102

      According to the php CHANGELOG, this problem was never resolved, although it sounds like someone _was_ going to take a look at it.  I wonder what ever developed of this bug..?

      I found many, many usenet postings referring to this same problem, all windows platforms, and all reporting problems with sessions.  There are a couple of quick code snippets in that url that you should be able to run as a test if you'd like.

      If this turns out to be the problem, it should be reported to the php developers so they can fix it (you could probably just add to bug #16102 to automatically re-open it).  It seems like more people would have complained about it by now, but who knows..?

      --Brad Fears

       
    • Nobody/Anonymous

      But why is it that the session variables seem to work when I am logged in? (except for a few that still give the error message).

      On the first page, once I log in, the majority of them work fine.

      -Tj

       
    • Nobody/Anonymous

      btw, thanks for the find (re: http://bugs.php.net/bug.php?id=16102 )

       
    • Nobody/Anonymous

      Something interesting, the following code works just fine (it seems to be because the existance of the var is checked first, then set if not already in existance)...

      <?
      session_start();

      if (!isset($_SESSION["count"])) {
          $HTTP_SESSION_VARS["count"] = 0;
      }

      $_SESSION["count"]++;

      echo $_SESSION["count"];
      ?>

      ..looking through the CodeCab code, I dont seem to see any place where these vars are registered/initialized prior to their values being evaluated.

      IIRC, this didnt used to be a problem (if the var didnt exist, it would automatically be created/added).  But wasnt this found to be a security risk, and then changed (I am trying to find the post/etc regarding this change in functionality... anyone else able to find this?)

      Might this be whats going on?

      Tj

       
      • Brad Fears

        Brad Fears - 2003-02-25

        The above code initializes the session variable using a deprecated method.  Check out this quote:

        "Use of $_SESSION (or $HTTP_SESSION_VARS with PHP 4.0.6 or less) is recommended for improved security and code readablity. With $_SESSION, there is no need to use the session_register(), session_unregister(), session_is_registered() functions. Session variables are accessible like any other variables."

        http://www.php.net/manual/en/ref.session.php

        A bug?

        BTW, the session variables are initialized in the 'user.php' script, which is why you must login before the session variables *should* be set.  As a workaround/test, you could always replace all instances of

        $_SESSION['var'] = whavever;

        with

        $HTTP_SESSION_VARS['var'] = whatever;

        --Brad Fears

         
    • Nobody/Anonymous

      I am having a hard time with this code... I dont consider myself a php sage yet, but this isnt making sense...

      1  <?php
      2  session_start();
      3  require_once("config.php");
      4
      5  if ($_SESSION['isloggedin'] == $glbl_hash) {
      6    $theme = $_SESSION['user_theme'];
      7  }
      8
      9  include_once("themes/$theme/header.php");
      10?>

      ...what it looks like (to me at least) is that on line 2 the
      session is started (no session vars created yet though).

      Then the config file is included, which does create the "$glbl_hash" variable.

      But by the time we get to line 5, we are trying to test the
      value of a variable that does not yet exist... correct?
      And this explains why I get the error...
      "Undefined index: isloggedin in C:\Inetpub\codebank\header.php on line 5"

      ...because this variable isnt created/initialized until the
      user.php script... but that is only called once a user is
      logged in.

      Is this right?

       
      • Nobody/Anonymous

        If I include this line between lines 2 and 3 (above) ...

        session_register("isloggedin");

        ...I no longer get the error message.  Additionally, without that line, when debugging the code, the _SESSION array is empty (it doesnt show an "isloggedin" item appearing with the array).  After adding this code, there is an isloggedin item within the array, and it doesnt choke here.

        Doesnt this point to a bug in the code and not in PHP (or my installation of PHP)?

        Tj

         
      • Brad Fears

        Brad Fears - 2003-03-22

        session_start() needs to be called for all php files which reference php session variables, hence the reason it is located in the header, which is loaded with every page.

        The user.php script actually initializes the session variables when a user logs in.  Otherwise, the session variables are not used, and the comparison with $glbl_hash is ignored since the user is not logged in.

        After logging in with the user.php script, you should have contents in your _SESSION array, but not until then.

        Does this make sense, or am I not explaining enough..?  Please let me know if your're still confused.

        --Brad Fears

         
      • Nobody/Anonymous

        "...The user.php script actually initializes the session variables when a user logs in. Otherwise, the session variables are not used..."
        But they are used arent they?

        Line 5 above...
        if ($_SESSION['isloggedin'] == $glbl_hash) {
        ...will be evaluated regardless of whether or not a user is logged in right?

        I am hearing (and correct me if I am not hearing you right) that you are telling me that the 5th line from the header.php wont be an issue because it wont be evaluated if a user isnt logged in... is that correct?

        But what I am saying I see when debugging the app is, code execution arrives at the 5th line in header.php regardless of whether or not a user is logged in.  When it does get to that statement, it chokes, because as you mentioned that variable does not yet exist (let alone have a value assigned to it yet).

        It kinda sounds like if in c++ if you tried to do...
        if (i = 1) {
        ...but you never defined i prior to evaluating its value?

        It almost looks like the variables need to be created (not neseccarily given a value) regardless of whether or not a user is logged in, right from the beginning of the script.  Or there might need to be a test like...
        if (isset(var)) {...
        ...before testing for the value of the var.

        Does this make any sense... am I losing my mind and the only one having the problem? ;)

        Thanks for you patience...
        Tj

         
        • Brad Fears

          Brad Fears - 2003-03-24

          No, you're not losing your mind, but you are (currently), the only one reporting a problem.

          In Line 5, the expression is evaluated regardless of whether or not the user is logged in.  If the user _is_ logged in, the rest of the condition is processed, if not, it's skipped...same if statement structures as c++.

          One of the advantages of php is that unlike c++, variables do not need to be explicitly initialized prior to evaluating them.  If they don't exist, then their value is considered zero.  So in the case of line 5, if the user has not logged in to set the 'isloggedin' session variable,  then $_SESSION['isloggedin'] is zero, and $_SESSION['isloggedin'] == $glbl_hash is false, so the rest of the if statement is skipped.

          NOTE: $glbl_hash is included with the config.php file in the header, so it should be defined in every script.

          What does your debugger show when it gets to this line?

          --Brad Fears

           
          • Nobody/Anonymous

            "One of the advantages of php is that unlike c++, variables do not need to be explicitly initialized prior to evaluating them."
            I know that was the case for quite some time, but unless i am mistaken, wasnt that changed reccently (some security issue, with people taking advantage of this auto var creation).  I am digging around in the change log now to see if I can find that; this did in fact change, and when it was changed.

            What version are you using? I could grab a copy of whatever version you are using and see if it works then.  I am currently using 4.3.1 (I know they claimed it shouldnt break functionality... but who knows eh ;)

            "So in the case of line 5, if the user has not logged in to set the 'isloggedin' session variable, then $_SESSION['isloggedin'] is zero, and $_SESSION['isloggedin'] == $glbl_hash is false, so the rest of the if statement is skipped."
            I think this is the problem.  When debugging, it bombs out here with an error ("Undefined index: 'isloggedin").  I set a bpx on this line, so it stops here prior to executing this line (and therefor, before any error is generated because of it).

            What I see is the _SESSION array exists as a variable, but there are no items in this array (its an empty array).

            If I add the code to add the 'isloggedin' item to the _SESSION array to before we get to line 5, then when it breaks, I see the _SESSION variable/array, with an item in the array called 'isloggedin', and the statement doesnt generate an error... and continues on (but ends up crashing in another place, for what seems to be the same reason).

            Tj

             
            • Brad Fears

              Brad Fears - 2003-03-24

              Here is the link you're looking for:

              http://www.php.net/manual/en/language.variables.predefined.php

              But don't mistake variables of a global scope with variables in general.  In C++, if you want to use a variable in an expression (like a comparison), you have to initialize it and then give it a value before comparing it.  In php, you can just compare it, regardless of whether it existed prior to the comparison expression.

              The 'register_globals' directive that you speak of just prevents users from doing things like modifying variables by way of the url.

              I'm using 3 different versions of php in my development environments, 4.0.6, 4.2.3, and 4.3.1.  All with linux, (I don't do windows), so I can't readily address windows issues.

              I'm kinda losing track of this thread, so bear with me.  Have you tried setting up a basic php script that initializes a session by registering session variables, similar to what we're doing?  If not, that might be a cleaner way to check for bugs.  You should be able to do something like this:

              <?php
              session_start();

              $_SESSION['userid'] = "joe_user";
              $_SESSION['isloggedin'] = "yes";

              echo "Session userid: ".$_SESSION['userid']."<br>";
              echo "Logged in?: ".$_SESSION['isloggedin']."<br>";

              if ($_SESSION['isloggedin'] == "yes") {
                  echo "Looks good.  Sessions are working properly.<br>";
              }

              ?>

              Stick that in a script and run it.  If it works properly, then the problem must go beyond the Session variables.

              --Brad Fears

               
              • Nobody/Anonymous

                Here is the ouput...

                Session userid: joe_user
                Logged in?: yes
                Looks good. Sessions are working properly.

                ...which is interesting... this partially disproves the original theory I had, which was that during the following line...

                if ($_SESSION['isloggedin'] == $glbl_hash) {

                ...from the header.php file.. the reason why I was getting the "Undefined index: isloggedin" error was because PHP would no longer create this var that didnt yet exist.

                In this code, it does create the var as it assigns the new value.  But I still think it might be something similiar to the what I was saying originally.  The line from header.php is trying to determine the value of a variable that hasnt been referenced yet... maybe PHP will create vars (or actually, based on your info & code... it obviously creates them) automatically when assigning a value to them, but not when they are involved in a conditional expression?

                This is sounding like its an issue with PHP, and not your app isnt it?

                Tj

                 
                • Brad Fears

                  Brad Fears - 2003-03-25

                  Okay, here's another script to try to prove/disprove your point:

                  <?

                  session_start();

                  if ($_SESSION['isloggedin'] != "yes") {

                      $_SESSION['isloggedin'] = "yes";
                      echo "Set 'isloggedin' to ".$_SESSION['isloggedin']."<br>";

                  } else {

                      echo "'isloggedin' has no value.<br>";

                  }

                  ?>

                  --Brad Fears

                   
                  • Nobody/Anonymous

                    Sorry, I didnt mean to come off as trying to aggressively prove a point... I just want to get this thing working :)

                    At any rate, here is the output of the 2nd script...

                    'isloggedin' has no value.

                    ...which is interesting.  As opposed to within the header.php file where this generates a "Undefined index: " error, the output as viewed in the browser doesnt give such an error.  However, within the debugger, it acts just as the line in header.php.

                    When viewing the local vars, I see the session variable/array once its created.  But there is no 'isloggedin' item within that array.  Attempting to execute it gives me the error mentioned, "Undefined index: "

                    This is driving me crazy... I am at a loss as to where to start troubleshooting this now.

                    Tj

                     
1 2 > >> (Page 1 of 2)

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.