Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
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
 
Old July 1st, 2004, 01:51 PM
Friend of Wrox
 
Join Date: Jun 2004
Location: Fairfield, Iowa, USA.
Posts: 101
Thanks: 0
Thanked 0 Times in 0 Posts
Default $_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
 
Old July 1st, 2004, 02:56 PM
Authorized User
 
Join Date: Jun 2004
Location: , , .
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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'];

 
Old July 1st, 2004, 03:08 PM
Friend of Wrox
 
Join Date: Jun 2004
Location: Fairfield, Iowa, USA.
Posts: 101
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

 
Old July 4th, 2004, 01:58 PM
Registered User
 
Join Date: Nov 2003
Location: varanasi, up, India.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi !
I suggest you to use dblquotes this way.
  echo $_POST["style_name"];
 
Old July 5th, 2004, 05:17 AM
Authorized User
 
Join Date: May 2004
Location: , , .
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
 
Old July 5th, 2004, 05:13 PM
Friend of Wrox
 
Join Date: Jun 2004
Location: Fairfield, Iowa, USA.
Posts: 101
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

 
Old July 6th, 2004, 09:09 PM
Authorized User
 
Join Date: Apr 2004
Location: Cincinnati, OH, USA.
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

 
Old July 7th, 2004, 09:20 AM
Friend of Wrox
 
Join Date: Jun 2004
Location: Fairfield, Iowa, USA.
Posts: 101
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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





Similar Threads
Thread Thread Starter Forum Replies Last Post
isset($_POST) summi_beniwal Beginning PHP 1 June 21st, 2008 07:13 AM
Problem using $_POST gkirk Beginning PHP 7 August 30th, 2006 07:21 AM
$_POST PROBLEM karlirvin PHP How-To 1 December 16th, 2005 03:14 AM
Chapter 12 - $_POST['redirect'] problem cshu BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 4 July 25th, 2005 08:14 PM
Getting nothing from $_POST['varName']; Kalisan Beginning PHP 10 February 3rd, 2005 02:37 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.