Page 1 of 1

Contents of string variable missing after space...

Posted: Wed Nov 06, 2002 9:18 am
by Skittlewidth
I've looked in just about every post containing the word "variable" (well almost) and no one has explained the following:

Why do some of my variables cut off at the first space when I echo them inside an html input box?

I can pass them around to other pages and databases and echo them out anywhere without a problem. If I pull the data out of MySQL and echo it inside a form there is no problem, but not if the variable was merely posted from another page, or even if it was defined earlier on on the same page for that matter!

I can echo the variable on the same page outside the form and it's all there, so why...... :?:

Code: Select all

<input type=text size=75 name=event value=<?php echo $_POST&#1111;'event'] ?>>

Posted: Wed Nov 06, 2002 9:27 am
by twigletmac
Because you don't quote the attributes in your HTML, try

Code: Select all

&lt;input type="text" size="75" name="event" value="&lt;?php echo $_POST&#1111;'event'] ?&gt;"&gt;
Mac

Posted: Wed Nov 06, 2002 10:10 am
by Skittlewidth
Ahh of course, stupid me. Earlier on I'd put the whole input box within php as an experiment and removed the quotes and when I rejuggled the code I hadn't put them back!

Code: Select all

<?php echo "<input type=text size=75 name=event value=";
	echo $event;
	echo ">";
          ?>
Well my boss made the same mistake so I don't feel too embarrassed! :oops:

Cheers twigletmac!

Posted: Wed Nov 06, 2002 11:55 am
by volka
there's no need for multiple echos ;)

Code: Select all

&lt;?php echo '&lt;input type="text" size="75" name="event" value="', $event, '" /&gt;'; ?&gt;