|
BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 | This is the forum to discuss the Wrox book Beginning PHP, Apache, MySQLWeb Development by Michael K. Glass, Yann Le Scouarnec, Elizabeth Naramore, Gary Mailer, Jeremy Stolz, Jason Gerner; ISBN: 9780764557446 |
|
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
July 1st, 2004, 01:51 PM
|
Friend of Wrox
|
|
Join Date: Jun 2004
Posts: 101
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
$_POST Problem
Can somebody tell me what is wrong whith this line:
echo "The of values of Style is $_POST['style_name']";
Thanks
Christian
__________________
Christian
|
July 1st, 2004, 02:56 PM
|
Authorized User
|
|
Join Date: Jun 2004
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
http://us3.php.net/manual/en/languag...string.parsing
Note the 4th example under arrays.
You can do:
echo "The values of Style is {$_POST['style_name']}";
or my preference:
echo "The values of Style is " . $_POST['style_name'];
|
July 1st, 2004, 03:08 PM
|
Friend of Wrox
|
|
Join Date: Jun 2004
Posts: 101
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks, I used the second one but wasn't sure why it was not working with just echo "$_POST['style_name']";. I will have to remember to put brackets.
:D
Christian
|
July 4th, 2004, 01:58 PM
|
Registered User
|
|
Join Date: Nov 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi !
I suggest you to use dblquotes this way.
echo $_POST["style_name"];
|
July 5th, 2004, 05:17 AM
|
Authorized User
|
|
Join Date: May 2004
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
No, you should use single quotes. The only time you should use double quotes is if you have to do something "special" inside them -- for instance, you want PHP to correctly use the variable "in $this string." If you don't need PHP to parse the stuff inside the quotes, then use single quotes, as it's more efficient.
For this reason, it is usually recommended to use single quotes inside all of your arrays.
Michael K. Glass
Author, Beginning PHP, Apache, MySQL Web Development
|
July 5th, 2004, 05:13 PM
|
Friend of Wrox
|
|
Join Date: Jun 2004
Posts: 101
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Which was exactly my point Buzzly I wanted to put the $_POST['variable'] inside an echo statement without having to put: . $_POST['variable']. As far as I know there php will complain if you put : echo "The vaues of variables is $_POST["variable"] ";
Christian
|
July 6th, 2004, 09:09 PM
|
Authorized User
|
|
Join Date: Apr 2004
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I think the difference though Christian is that you were trying to echo a value in an array, which you have to reference a bit differently than a plain old variable.
This works:
echo "My name is $name";
and so does this:
echo "My name is " . $name;
But this doesn't:
echo "My name is $_POST['name']";
because you are referencing a value in an array, as jason offered the link to the explanation. When referencing an array, you either need to use braces or separate the value out with .'s
|
July 7th, 2004, 09:20 AM
|
Friend of Wrox
|
|
Join Date: Jun 2004
Posts: 101
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks Elizabeth. I got that after reading Jason post that is why if you see my second posting you will notice I acknowledge that. My last posting was with regard to the sugestion to use double quotes instead on single ones around the index of the array.
Christian
|
|
|