Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 21st, 2005, 5:29 PM   #1
Epoch_Apex
Newbie
 
Join Date: Oct 2005
Location: Downtown Toronto
Posts: 21
Rep Power: 0 Epoch_Apex is on a distinguished road
What does T_ENCAPSED_AND_WHITESPACE mean?

Hi,

I'm trying to make a simple form that propagates a newsletter's database.

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in line 164

Here's line 164:

$query2 = "INSERT INTO `audrey` ( `email`, `name` , `age` , `location`) VALUES ('$_POST['address']' , '$_POST['name']' , '$_POST['age']' , '$_POST['location']');";

Other than simply solving my syntax, can someone please tell me what it means? I can't seem to find these terms on php.net.
Epoch_Apex is offline   Reply With Quote
Old Nov 21st, 2005, 6:02 PM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Quote:
'$_POST['address']'
Notice the attempt to use "nested" quotes. Refer to the PHP manual and pick your preferred escape route.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Nov 21st, 2005, 6:10 PM   #3
tempest
Programming Guru
 
tempest's Avatar
 
Join Date: Oct 2004
Posts: 1,041
Rep Power: 6 tempest is on a distinguished road
Send a message via ICQ to tempest Send a message via AIM to tempest Send a message via Yahoo to tempest
'{$_POST['address']}'

Would probably be the easiest method..
__________________

tempest is offline   Reply With Quote
Old Nov 22nd, 2005, 8:58 AM   #4
Epoch_Apex
Newbie
 
Join Date: Oct 2005
Location: Downtown Toronto
Posts: 21
Rep Power: 0 Epoch_Apex is on a distinguished road
Thanks guys that helps. Being a bit of a noob, its hard to know where I'm going wrong sometimes and than I delve into a lot of needless research. Those php errors are hard to understnad.
Epoch_Apex is offline   Reply With Quote
Old Nov 22nd, 2005, 9:06 AM   #5
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
To be honest with you, unlike C/C++, I rarely look up those PHP thangies. I go where the line number says and can usually see immediately precisely how I've stuck my head where the sun don't shine. The exception is a missing brace. That usually refers you to the end of the file as the location of the error. When you get that one, warm up your brace matcher.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Nov 22nd, 2005, 11:11 AM   #6
Lich
Professional Programmer
 
Lich's Avatar
 
Join Date: May 2005
Location: Detroit
Posts: 254
Rep Power: 4 Lich is on a distinguished road
Send a message via AIM to Lich Send a message via MSN to Lich
[PHP]'$_POST[address]'[/PHP]
This works just as well too.

Typically for insert queries with a lot of variables I like to stick them all into other variables.

[PHP]$address = $_POST['address'];[/PHP]
for example. Then use that when you write your query
__________________
--John Cruz
Web Developer
www.cruzweb.net
Lich is offline   Reply With Quote
Old Nov 22nd, 2005, 2:06 PM   #7
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
While it works, it only works because the PHP parser is extremely lenient. It's not valid code - if you turn on warning messages, you'll see PHP grumble about it. The manual's an excellent tool, and generally, what it says, goes.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:35 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC