Contents of string variable missing after space...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Skittlewidth
Forum Contributor
Posts: 389
Joined: Wed Nov 06, 2002 9:18 am
Location: Kent, UK

Contents of string variable missing after space...

Post 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'] ?>>
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
User avatar
Skittlewidth
Forum Contributor
Posts: 389
Joined: Wed Nov 06, 2002 9:18 am
Location: Kent, UK

Post 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!
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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;
Post Reply