Problem in concatenation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mukeshrasm
    Contributor
    • Nov 2007
    • 254

    #1

    Problem in concatenation

    Hi

    I got problem while concatenating the strings here is the code

    <a href=\"javascri pt:openit('View _Full_Image.php ?id=".$_rows['Image_Id']."&name=".$_nam e."')\"><img src=\"".$_rows['File_Path']."\" height=\"20\" width=\"20\">

    $_name stores the full name(title) of the image.

    it shows the full name on the link but when I echo this to next page it shows only the first string means not showing the string after space.

    like $name="mukesh kumar"
    but on next page $name only shows mukesh. so how can i do that. I also tried to use the \\ but then it is showing nothing.
  • globalprompt
    New Member
    • Dec 2007
    • 1

    #2
    Originally posted by mukeshrasm
    Hi

    I got problem while concatenating the strings here is the code

    <a href=\"javascri pt:openit('View _Full_Image.php ?id=".$_rows['Image_Id']."&name=".$_nam e."')\"><img src=\"".$_rows['File_Path']."\" height=\"20\" width=\"20\">

    $_name stores the full name(title) of the image.

    it shows the full name on the link but when I echo this to next page it shows only the first string means not showing the string after space.

    like $name="mukesh kumar"
    but on next page $name only shows mukesh. so how can i do that. I also tried to use the \\ but then it is showing nothing.
    Try to use urlencode() and urldecode(). It can solve th problem

    Comment

    • mukeshrasm
      Contributor
      • Nov 2007
      • 254

      #3
      Originally posted by globalprompt
      Try to use urlencode() and urldecode(). It can solve th problem
      In this code where I need to write urlencode and where to write urldecode.

      Comment

      • Markus
        Recognized Expert Expert
        • Jun 2007
        • 6092

        #4
        it took me forever to work out what you were talking about :P

        Do urlencode() on your $_name

        [php]
        &name=".urlenco de($_name)."
        [/php]

        Hope that helps :)

        Comment

        • mukeshrasm
          Contributor
          • Nov 2007
          • 254

          #5
          Originally posted by markusn00b
          it took me forever to work out what you were talking about :P

          Do urlencode() on your $_name

          [php]
          &name=".urlenco de($_name)."
          [/php]

          Hope that helps :)
          No this also did not worked on hyperlink it shows the string like mukesh+kumar but when I retrieve this value on other page it shows only mukesh. on other page I used urldecode as well.

          Comment

          • Markus
            Recognized Expert Expert
            • Jun 2007
            • 6092

            #6
            Don't use url decode..

            just use $_GET - it'll print out the string and replace + with a space; like the original.

            :)

            Comment

            • sumeetk
              New Member
              • Dec 2007
              • 6

              #7
              So we create a variable to contain a space character as well:

              $Space = " ";

              You should note that this quite different from having an empty string. An empty string contains nothing at all, while a string with a space contains a character, albeit an invisible one. Spaces of course can be concatenated just like any other text:

              $Car = $CarType . $Space . $EngineSize;

              This would produce the desired, nicely spaced-out text Cadillac 2.6. Of course, there's no reason why you can't concatenate variables with actual text phrases as well:

              $Car = "Buick" . $Space . "2.0";

              Here we added text to a variable to more text, which produces the response Buick 2.0. There would also have been nothing wrong with the following line either:

              $Car = "Buick" . " " . "2.0";

              Comment

              Working...