Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder
    Join Date
    May 2005
    Posts
    224
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Variable echoeing out incorrectly

    Sorry about thread title. Couldn't think of a good one.

    Right now I have this hidden form field:
    PHP Code:
    echo '<input type="hidden" name="store" value="' $img_html '">'
    the variable $img_html contains something like this:
    Code:
    <center><img src="blahblah.jpg"></center>
    so when I view the page with that hidden form, I see "blahblah.jpg" on the page itself, and in the source I see:
    Code:
    <input type="hidden" name="store" value="<center><img src="blahblah.jpg"></center>">
    But when I submit the form, I do not get what is in the value field, and the ' "> ' at the end of the above coode shows up on the page itself.


    How do I make it so the value of the form is correct so it submits the <center>...</center> and doesnt echo it out?

  • #2
    Regular Coder musher's Avatar
    Join Date
    Jan 2005
    Location
    Minnesota
    Posts
    203
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Crazydog, show the code that you use to set $img_html.
    Thanks
    Jim M

    "Lord, help me to become the person my dog thinks I am" - Dawn Ewing
    "If you must know. Yes, I do enjoy running after the dog sled when I fall off" - Me

    www.huskyzone.com -- Woodland Siberians

  • #3
    Regular Coder
    Join Date
    May 2005
    Posts
    224
    Thanks
    1
    Thanked 0 Times in 0 Posts
    PHP Code:
    <?php
    $song 
    $_POST['Song'];
    $Dot $_POST['DotNo'];
    $counts $_POST['Counts'];
    $measures $_POST['Measures'];
    $side $_POST['side'];
    $AB $_POST['AB'];
    $line $_POST['Line'];
    $hash $_POST['hashnumber'];
    $YardLine $_POST['Yardline'];
    $steps $_POST['steps'];
    $InOut $_POST['InOut'];

    $img_html '<center><img src="http://viralfix.dev.thebuddygroup.com/test/dotbook.php?Song=' $song;
    $img_html .= '&DotNo=' $Dot;
    $img_html .= '&Counts=' $counts;
    $img_html .= '&Measures=' $measures;
    $img_html .= '&side=' $side;
    $img_html .= '&AB=' $AB;
    $img_html .= '&Line=' $line;
    $img_html .= '&hashnumber=' $hash;
    $img_html .= '&Yardline=' $YardLine;
    $img_html .= '&steps=' $steps;
    $img_html .= '&InOut=' $InOut '"></center>';
    print 
    $img_html;
    ?>
    That's all being drawn from a form on a previous page, which works fine.

  • #4
    Regular Coder musher's Avatar
    Join Date
    Jan 2005
    Location
    Minnesota
    Posts
    203
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok this

    PHP Code:
    <?php
    $song 
    "Song";
    $Dot "DotNo";
    $counts "Counts";
    $measures "Measures";
    $side "side";
    $AB "AB";
    $line "Line";
    $hash "hashnumber";
    $YardLine "Yardline";
    $steps "steps";
    $InOut "InOut";

    $img_html '<center><img src="http://viralfix.dev.thebuddygroup.com/test/dotbook.php?Song=' $song;
    $img_html .= '&DotNo=' $Dot;
    $img_html .= '&Counts=' $counts;
    $img_html .= '&Measures=' $measures;
    $img_html .= '&side=' $side;
    $img_html .= '&AB=' $AB;
    $img_html .= '&Line=' $line;
    $img_html .= '&hashnumber=' $hash;
    $img_html .= '&Yardline=' $YardLine;
    $img_html .= '&steps=' $steps;
    $img_html .= '&InOut=' $InOut '"></center>';
    print 
    $img_html;
    ?>
    returns

    Code:
    <center><img src="http://viralfix.dev.thebuddygroup.com/test/dotbook.php?Song=Song&DotNo=DotNo&Counts=Counts&Measures=Measures&side=side&AB=AB&Line=Line&hashnumber=hashnumber&Yardline=Yardline&steps=steps&InOut=InOut"></center>
    What are you looking to be returned?
    Thanks
    Jim M

    "Lord, help me to become the person my dog thinks I am" - Dawn Ewing
    "If you must know. Yes, I do enjoy running after the dog sled when I fall off" - Me

    www.huskyzone.com -- Woodland Siberians

  • #5
    Regular Coder
    Join Date
    May 2005
    Posts
    224
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Heres an example of the problem.
    http://www.dotbooks.org/exp/image.php

    1) Look at the source and look at the value of the hidden form.
    2) "Submit" it. The broken image should be the value of the hidden form, correct?
    3) Look at the source, and you'll see the problem.
    Last edited by Crazydog; 11-13-2006 at 04:08 AM.

  • #6
    Senior Coder
    Join Date
    Aug 2005
    Posts
    1,119
    Thanks
    2
    Thanked 1 Time in 1 Post
    you have html inside your from "value". That is not allowed. Try getting rid of that and seeing if it works.

  • #7
    Regular Coder
    Join Date
    May 2005
    Posts
    563
    Thanks
    0
    Thanked 3 Times in 3 Posts
    Try using htmlspecialchars() like this

    PHP Code:
    print htmlspecialchars($img_html); 


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •