OK, if i do :
echo " <B>$desc<B>";
I have this as an answer ;
Baxter 3 poches de lait 2%
when i try to transfer the value of $desc into the variable NAME (for my cart)
Here is the code : echo " <input type=hidden name=\"NAME\" value= $desc > ";
I got this in the name variable : Baxter (only the first word)
if i get into the sql database and modify the description by removing (two) 2 blanks ...
Baxter3poches de lait 2%
I got this in the shopping cart :
Baxter3poches
why this command : echo " <input type=hidden name=\"NAME\" value= $desc > ";
is transfering only the first word of the description ?
thank guys.
transfering variable value... something funny here..
Moderator: General Moderators
-
grabber_grabbs
- Forum Commoner
- Posts: 60
- Joined: Mon Oct 10, 2011 6:13 pm
Re: transfering variable value... something funny here..
You need quotes around the value.
Code: Select all
echo "<input type=\"hidden\" name=\"name\" value=\"{$desc}\" />";-
grabber_grabbs
- Forum Commoner
- Posts: 60
- Joined: Mon Oct 10, 2011 6:13 pm
Re: transfering variable value... something funny here..
Finally this did the trick
echo " <input type=hidden name=NAME value=\"{$desc}\" />";
now, why $desc gave only the first word ?
where can i have info on php syntax.... "{variable}"
does all the variable in PhP has to be transfered like this ?
how come if i write
newvar = $desc
at the end, newvar will have the same value/content of $desc...
thanks again
echo " <input type=hidden name=NAME value=\"{$desc}\" />";
now, why $desc gave only the first word ?
where can i have info on php syntax.... "{variable}"
does all the variable in PhP has to be transfered like this ?
how come if i write
newvar = $desc
at the end, newvar will have the same value/content of $desc...
thanks again
Re: transfering variable value... something funny here..
HTML attribute values need to be enclosed in quotes. While <foo val=1> will work, it's still incorrect. <foo val=some string with spaces> will never work; it will always interpret as val=some.
You don't need braces around a variable when you're echoing the variable inside a double-quoted string, but you'll run into problems with things like:
Enclosing the variable in braces eliminates that problem, so I just do it as a matter of course.
You don't need braces around a variable when you're echoing the variable inside a double-quoted string, but you'll run into problems with things like:
Code: Select all
echo "Some string $array['key']";