problem in passing argument

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shreedhan
    New Member
    • Jul 2007
    • 52

    problem in passing argument

    HI again,


    OK, now I have a page pictures.php
    and I am using following code :
    [PHP]printf("<a href=\"pictures .php?name=%s\"> ",urlencode($va l[0]));
    print ("<img src=\"$val[0]\" width=100%)/></a>");[/PHP]

    the problem is no value is stored in $name in pictures.php
    I don't get anything when i print $name.

    Need a help.
    Thanks
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    There's no reference to '$name'

    =/

    Comment

    • shreedhan
      New Member
      • Jul 2007
      • 52

      #3
      Originally posted by markusn00b
      There's no reference to '$name'

      =/
      I have included following line
      [PHP]print ("$name");[/PHP]
      in pictures.php
      just after above code.

      thanks

      Comment

      • Markus
        Recognized Expert Expert
        • Jun 2007
        • 6092

        #4
        $name is empty?

        I'm really sorry, it's just i can't know what your code is.. you have to show me.

        Comment

        • shreedhan
          New Member
          • Jul 2007
          • 52

          #5
          OK,
          here is the code I'm using
          [PHP]<?php
          $loginid=$_SESS ION['loginid'];
          mysql_connect(' localhost','use r','user');
          mysql_select_db ('test');
          $query="select name from pictures where loginid='$login id'";
          $result=mysql_q uery($query);
          print("<table width=95% align=center cellspacing=4> <tr>");
          $count=0;
          while($val=mysq l_fetch_array($ result))
          {
          if ($count++<5)
          print("<td width=20%>");
          else { print("</tr><tr><td width=20%>"); $count=0; }
          printf("<a href=\"pictures .php?name=%s\"> ",urlencode($va l[0]));
          print ("<img src=\"$val[0]\" width=100%)/></a>");
          print("</td>");

          }
          if ($count<5)
          while ($count++<5) print ("<td width=20%>&nbsp ;</td>");

          print("</tr></table>");
          print ("\n<br/><center><img src=\" $name \"><br/>");

          ?>[/PHP]

          When I see the source code in my browser it doesn't show anything in place of $name in the last line

          Thanks

          Comment

          • rpnew
            New Member
            • Aug 2007
            • 189

            #6
            Originally posted by shreedhan
            OK,
            here is the code I'm using
            [PHP]<?php
            $loginid=$_SESS ION['loginid'];
            mysql_connect(' localhost','use r','user');
            mysql_select_db ('test');
            $query="select name from pictures where loginid='$login id'";
            $result=mysql_q uery($query);
            print("<table width=95% align=center cellspacing=4> <tr>");
            $count=0;
            while($val=mysq l_fetch_array($ result))
            {
            if ($count++<5)
            print("<td width=20%>");
            else { print("</tr><tr><td width=20%>"); $count=0; }
            printf("<a href=\"pictures .php?name=%s\"> ",urlencode($va l[0]));
            print ("<img src=\"$val[0]\" width=100%)/></a>");
            print("</td>");

            }
            if ($count<5)
            while ($count++<5) print ("<td width=20%>&nbsp ;</td>");

            print("</tr></table>");
            print ("\n<br/><center><img src=\" $name \"><br/>");

            ?>[/PHP]

            When I see the source code in my browser it doesn't show anything in place of $name in the last line

            Thanks
            Hi,

            Well i didnt find any place in your code where you are assigning any value to '$name' so it will be empty..... what do you exactly want '$name' to print??

            if i'm not understanding your code then let me know

            Regards,
            RP

            Comment

            • shreedhan
              New Member
              • Jul 2007
              • 52

              #7
              Originally posted by rpnew
              Hi,

              Well i didnt find any place in your code where you are assigning any value to '$name' so it will be empty..... what do you exactly want '$name' to print??

              if i'm not understanding your code then let me know

              Regards,
              RP
              Well, I think I should explain my code.

              I am trying to make a page for pictures in which user will see thumnail-size pictures first. And when he clicks the picture, he will see the actual size of image later on the same page.

              Ok, now I have included this code in line no. 14
              [PHP]#
              printf("<a href=\"pictures .php?name=%s\"> ",urlencode($va l[0]));[/PHP]

              Isn't this suppose to assign value of urlencode($val[0]) to name ??
              and when clicked in the link, isn't this code supposed to pass value of $name to pictures.php (which is the same page in my case).

              So, I need the value of $name so as to know which image has the user clicked.

              I think, that clears my problem and your doubt.

              But please do help me
              Thanks

              Comment

              • Markus
                Recognized Expert Expert
                • Jun 2007
                • 6092

                #8
                Have you tried printing just $val[0]?

                Also, don't say $name.. it makes people look for a variable called $name in your script when it isnt there. You're just reffering to the name= in the url.

                Comment

                • shreedhan
                  New Member
                  • Jul 2007
                  • 52

                  #9
                  Hi,
                  thanks for your suggestions.

                  I have tried printing the value of $val[0] as well and it's working fine.
                  I can see in the page source as well as the url like pictures.php?na me=something but it seems name is not taking that value.
                  later when I include
                  [PHP]print ("\n<br/><center><img src=\" $name \"><br/>");[/PHP]
                  name doesn't have any value.

                  Thanks

                  Comment

                  • Markus
                    Recognized Expert Expert
                    • Jun 2007
                    • 6092

                    #10
                    Are you using $_GET['name'];

                    To retrieve the name?

                    Comment

                    • shreedhan
                      New Member
                      • Jul 2007
                      • 52

                      #11
                      Hey,

                      I didn't use $_GET['name'] to retrieve the value.
                      Its working after I user $_GET array.

                      thanks for all your help and support.
                      I got that working now.

                      Thanks again

                      Comment

                      • Markus
                        Recognized Expert Expert
                        • Jun 2007
                        • 6092

                        #12
                        Originally posted by shreedhan
                        Hey,

                        I didn't use $_GET['name'] to retrieve the value.
                        Its working after I user $_GET array.

                        thanks for all your help and support.
                        I got that working now.

                        Thanks again
                        Haha, after all that!

                        No probs, post back whenever :)

                        Comment

                        Working...