Program Error...?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • niths
    New Member
    • Mar 2010
    • 18

    Program Error...?

    hi all,
    i dont know what the error with this program.I cannot get the value.

    ----sample.php-----

    Code:
    <?php
    ob_start();
    @session_start();
    require_once ("damn.php");
    createsessions(sex);
    ?>
    <html>
    <body>
    <form action="sample2.php" method="post">
    <input type="radio" name="sex" value="male" /> Male
    <br />
    <input type="radio" name="sex" value="female" /> Female
    <input type="submit" name="Submit"  value="Submit">
    </form>
    </body> 
    </html>
    -------sample2.php-------

    Code:
    <?php
      $sex=$_SESSION[sex];
      echo $sex;
    ?>
    -------damn.php------

    Code:
    <?php
    function createsessions($sex)
    {
        session_register();
        $_SESSION["sex"] = $sex;
    }
    ?>
    wen i press submit button i am not getting the echo value i am not knowing wer the error is....? so can any one...?
    thanks in advance...
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    You're going to need to compile the extension. What OS are you on?

    Comment

    • niths
      New Member
      • Mar 2010
      • 18

      #3
      Originally posted by Markus
      You're going to need to compile the extension. What OS are you on?
      Windows XP Professional but why...?
      Is the code i had writen is correct...? can we create session like that. can we call the session value like that....?
      i dont know why it is not printing the value.

      Comment

      • Markus
        Recognized Expert Expert
        • Jun 2007
        • 6092

        #4
        You be savvy to C programming, would you, i.e. have a compiler on your box (Visual Studio C++, or something like)?

        Comment

        • niths
          New Member
          • Mar 2010
          • 18

          #5
          Originally posted by Markus
          You be savvy to C programming, would you, i.e. have a compiler on your box (Visual Studio C++, or something like)?
          sorry i dont understand wat ur saying..
          why do we need that..?
          u r asking wat compiler i am having right. i am using php debugger(Nusphe re)

          Comment

          • Markus
            Recognized Expert Expert
            • Jun 2007
            • 6092

            #6
            Whoa. For some reason, I posted this in the wrong thread. My bad. :)

            Comment

            • Atli
              Recognized Expert Expert
              • Nov 2006
              • 5062

              #7
              Originally posted by niths
              ...
              There are a few problems with your code that you should fix before anything else.
              • First of all, as always when you are developing your code, you should turn on the error messages. Otherwise you are flying blind.
              • Remove the @ from the session_start function. It's rarely a good idea to suppress errors, especially errors relating to functions that would cripple your application when they fail. - If you want to hide the errors from your visitors, use the Error and Logging config directives to hide and/or re-route the error messages, but always keep them enabled in one way or another, and use them when you are debugging your code. (Use the ini_set function to change them, or simply change them in your php.ini file.)
              • Always quote strings! PHP is smart (or dumb, depending on the perspective) enough to convert unquoted text into a string for you, but that's no excuse.
                [code=php]
                // INCORRECT!
                $_SESSION[whatever] = "whatever";

                // Correct
                $_SESSION["whatever"] = "whatever";[/code]
                [code=php]// INCORRECT
                $something = something;

                // Correct
                $something = "something" ;[/code]
                [code=php]// INCORRECT!
                functionCall(so mething);

                // Correct
                functionCall("s omething");[/code]
                And so on...
              • The session_registe r function is deprecated and should therefore be avoided. But even so, the way you use it in your code is not the right way. - Line #5 of your damn.php file is the right way to set a session variable. It's best to just forget the session_registe r function altogether.


              Try to fix that and see if you get anywhere. If not, post any error messages you get here and tell us exactly what is happening, or not happening.

              Comment

              Working...