php 5 and uninitialized variables

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Guest's Avatar

    #16
    Re: php 5 and uninitialized variables

    > <?[color=blue]
    > $pageTitle = "User Menus";
    > require_once "../inc/head.inc.php";[/color]

    It is probably the above code giving you problems? Try this... Change the
    following code:

    require_once "../inc/head.inc.php";

    to:

    if (!include_once( "../inc/head.inc.php")) exit('Unable to open
    "../inc/head.inc.php"') ;

    If require_once has a problem your script will just exit quietly.

    _______________ _______________ ______
    Wil Moore III, MCP | Integrations Specialist


    Comment

    • steve

      #17
      Re: php 5 and uninitialized variables

      | It is probably the above code giving you problems? Try this... Change the
      | following code:
      |
      | require_once "../inc/head.inc.php";
      |
      | to:
      |
      | if (!include_once( "../inc/head.inc.php")) exit('Unable to open
      | "../inc/head.inc.php"') ;
      |
      | If require_once has a problem your script will just exit quietly.


      thanks for your thoughts, however i know that the required page is being
      included. it only displays incorrectly when i access an uninitialized
      variable.

      i've removed php 5 and reverted to php 4.3. the problem is gone now. i'll
      probably fully develop this small site, uninstall completely 4.3, then
      install 5 and see what blows up.

      thanks again,

      steve


      Comment

      • Chung Leong

        #18
        Re: php 5 and uninitialized variables

        "steve" <a@b.com> wrote in message news:es%zd.4275 $J26.1425@fe03. lga...[color=blue]
        > that's what it was originally set to...i changed it to only show errors.[/color]
        in[color=blue]
        > combination with that, i've added:
        >
        > $id = isset($_REQUEST['id']) ? $_REQUEST['id'] : 0;
        >
        > and cleared my browser's history. there doesn't seem to be a problem with
        > the above now.
        >
        > i guess that solve the script-stoppage problem, but i'd like to know why
        > uninitialized variable useage would cause the problem *and* not even give[/color]
        an[color=blue]
        > error message of some kind.[/color]

        Quite possibly a bug in PHP 5. Sounds like one that causes the server to
        sigfault, since PHP didn't even manage to flush the output buffer.


        Comment

        • steve

          #19
          Re: php 5 and uninitialized variables

          | Quite possibly a bug in PHP 5. Sounds like one that causes the server to
          | sigfault, since PHP didn't even manage to flush the output buffer.

          i was fearful of that and, all indications are that it is so since reverting
          to php 4.3 and running the same code gives no errors and produces exactly
          the expected results.


          Comment

          • Daniel Tryba

            #20
            Re: php 5 and uninitialized variables

            In comp.lang.php steve <a@b.com> wrote:[color=blue]
            > | Quite possibly a bug in PHP 5. Sounds like one that causes the server to
            > | sigfault, since PHP didn't even manage to flush the output buffer.
            >
            > i was fearful of that and, all indications are that it is so since reverting
            > to php 4.3 and running the same code gives no errors and produces exactly
            > the expected results.[/color]

            At the same level of error_reporting ?

            Comment

            • jblanch

              #21
              Re: php 5 and uninitialized variables

              Hell off topic with them.. but you might want to check
              htmlspecialchar s() on that script there.. sql injections visible at
              first glance..

              but anyways, you were on the right track with isset, i suggest just
              making a simple function?
              that is, if you are trying to assign a post/get variable to a php
              variable... you could do somthign like this..

              function setvar($var){
              if(isset($_POST[$var])){
              return $_POST[$var];
              }
              if(isset($_GET[$var])){
              return $_GET[$var];
              }
              return "";
              }

              then just use
              $p = setvar("p");
              and p will be either the get, post, or "".

              but the method you are using is doing one isset, with my local apache
              it brings up errors like you have when i have unassigned variables, so
              the easiest and safest thing to do is set them to null, then use the
              isset..

              $p = "";
              if(isset($_GET['p'])) $p = $_GET['p'];

              that will cause p to only be set with the get value if there is one..
              (duh)

              Comment

              • steve

                #22
                Re: php 5 and uninitialized variables


                "Daniel Tryba" <spam@tryba.inv alid> wrote in message
                news:41d205ba$0 $6212$e4fe514c@ news.xs4all.nl. ..
                | In comp.lang.php steve <a@b.com> wrote:
                | > | Quite possibly a bug in PHP 5. Sounds like one that causes the server
                to
                | > | sigfault, since PHP didn't even manage to flush the output buffer.
                | >
                | > i was fearful of that and, all indications are that it is so since
                reverting
                | > to php 4.3 and running the same code gives no errors and produces
                exactly
                | > the expected results.
                |
                | At the same level of error_reporting ?

                hard to say "same" here, as i tried all different combinations of error
                reporting on php 5. it simply stopped spewing output when it hit an
                uninitialized variable. with php 4.3, i have e_all & ~ e_notice...whic h is
                the default i believe.

                i don't know if it made a difference in installation, but i did not
                uninstall php 4.3 prior to the php 5 install...which did not require a
                re-boot once complete (and i hadn't rebooted manually either). when the
                problem showed itself and i could not resolve it, i uninstalled php 4.3. the
                problem persisted. i uninstalled php 5 (*did* require a reboot) then
                reinstalled php 4.3. may just have had a dll from 4.3 in memory until the
                reboot...or something like that.

                when i retry php 5, i'll take off php 4.3, reboot, then install 5 and see
                what happens with the app then.

                thanks for everyone's help.


                Comment

                • steve

                  #23
                  Re: php 5 and uninitialized variables

                  | Hell off topic with them.. but you might want to check
                  | htmlspecialchar s() on that script there.. sql injections visible at
                  | first glance..

                  yeah, there are a couple of things i'll go back and fix after i get the bulk
                  of the script written...i need to add data-prep (validation, error
                  reporting, etc.) which will be responsible for prep-ing it for use with sql
                  among other things.

                  mainly just working out connectivity, basic sql, and page layout(s) now.

                  | but anyways, you were on the right track with isset, i suggest just
                  | making a simple function?

                  i actually changed it to use $_request (which uses the php.ini settings for
                  variable assignment order):

                  $id = isset($_REQUEST['id']) ? $_REQUEST['id'] : 0;

                  this accomplishes the same thing as the example you posted and always sets
                  the var.

                  thanks for your thoughts and suggestions!

                  cheers,

                  steve


                  Comment

                  Working...