...

View Full Version : Variable echoeing out incorrectly



Crazydog
11-13-2006, 01:04 AM
Sorry about thread title. Couldn't think of a good one.

Right now I have this hidden form field:

echo '<input type="hidden" name="store" value="' . $img_html . '">';

the variable $img_html contains something like this:

<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:

<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?

musher
11-13-2006, 01:18 AM
Crazydog, show the code that you use to set $img_html.

Crazydog
11-13-2006, 01:22 AM
<?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.

musher
11-13-2006, 01:31 AM
ok this


<?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


<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?

Crazydog
11-13-2006, 03:15 AM
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.

thesavior
11-13-2006, 04:13 AM
you have html inside your from "value". That is not allowed. Try getting rid of that and seeing if it works.

SeeIT Solutions
11-13-2006, 04:41 AM
Try using htmlspecialchars() like this


print htmlspecialchars($img_html);



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum