problem passing 1-3 word variable

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
rfigley
Forum Commoner
Posts: 70
Joined: Sun Apr 21, 2002 7:10 pm

problem passing 1-3 word variable

Post by rfigley »

I'm trying to pass a variable from one page to the next to be used in a final query on a third page.

The variable is one to 3 words. It is selected via pulldown menu, then is taken to the page of the next pulldown, which is a name selection and is two words. Both of these go to the final query where they are both used in a query.

The first variable keeps getting cut off to only one word. The second one stays in tact with it's two words. If the first variable is only one word, there is no problem and the query on the 3rd page works fine. But if its 2 or more of course the query doesn;t work. I am using
<input type=hidden name=field_name value=$variable>

to pass it from the second page to the 3rd page to be used in the query, but as I said, keeps getting cut to the first word only. What am I missing here?
Agent Dwarf
Forum Newbie
Posts: 9
Joined: Sat Sep 21, 2002 2:03 pm

Post by Agent Dwarf »

Is that echo'd/print'd in a PHP script, or in plain HTML?

If it's in PHP, try:

Code: Select all

echo '&lt;input type=hidden name="field_name" value="' . $variable . '" /&gt;';
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

you have to use quotes

echo "<input type=\"hidden\" name=\"field_name\" value=\"$variable\">";

in php
rfigley
Forum Commoner
Posts: 70
Joined: Sun Apr 21, 2002 7:10 pm

Post by rfigley »

Yes, it's in php. Thanks, I was getting errors with the quotes and forgot to escape them instead of eliminating them. Duh!
Post Reply