FutureQuest, Inc. FutureQuest, Inc. FutureQuest, Inc.

FutureQuest, Inc.
Go Back   FutureQuest Community > General Site Owner Support (All may read/respond) > PHP, Perl, Python and/or MySQL
User Name
Password  Lost PW

Reply
 
Thread Tools Search this Thread Display Modes
Old 06-25-2009, 11:22 AM   Postid: 174870
pvmaddox
Registered User

Forum Notability:
0 pts: Even-handed
[Post Feedback]
 
Join Date: May 2007
Posts: 12
My form variables don't work anymore

Evidently in the new version of PHP the values sent in the command from the form are no longer available as $variable, but must be accessed using $_post['variable']. My MySQL Insert command no longer works using
$sql = "INSERT INTO q<removed> (K_Q<removed>,F<removed>,L<removed>) values VALUES ($_POST['K_Q<removed>'],$_POST['F<removed>'],$_POST['L<removed>'])";
gives me an indecipherable error message
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /big/dom/x<removed>.php on line 35

What am I doing wrong?
__________________
Phyllis

Last edited by Terra : 06-25-2009 at 02:15 PM. Reason: Munged the script name to prevent it from being directly attacked - now that they know what to attack...
pvmaddox is offline   Reply With Quote
Old 06-25-2009, 11:48 AM   Postid: 174876
kitchin
Site Owner

Forum Notability:
1163 pts: A True Crowd-pleaser!
[Post Feedback]
 
Join Date: Jan 2001
Location: Virginia
Posts: 2,992
Re: My form variables don't work anymore

Take out the single quotes. It's a weird aspect of PHP double-quoting. By the way, that code is unsafe unless you trust your users not to craft any old MySQL statement they want.
kitchin is offline   Reply With Quote
Old 06-25-2009, 11:51 AM   Postid: 174877
kitchin
Site Owner

Forum Notability:
1163 pts: A True Crowd-pleaser!
[Post Feedback]
 
Join Date: Jan 2001
Location: Virginia
Posts: 2,992
Re: My form variables don't work anymore

The quoting is explained by the 'banana' examples here:
http://us2.php.net/manual/en/languag...string.parsing
kitchin is offline   Reply With Quote
Old 06-25-2009, 12:39 PM   Postid: 174884
 Kevin
Systems Administrator
 
Kevin's Avatar
 
Join Date: Aug 2001
Location: Orlando, FL
Posts: 2,481
Re: My form variables don't work anymore

Kitchen is right. Any input needs to be sanitized before using it in an SQL query or even worse shell code.

__________________
Kevin
Kevin is offline   Reply With Quote
Old 06-25-2009, 01:59 PM   Postid: 174885
pvmaddox
Registered User

Forum Notability:
0 pts: Even-handed
[Post Feedback]
 
Join Date: May 2007
Posts: 12
Re: My form variables don't work anymore

Thanks. I no longer get the error message, but it still won't save the record to the database. My $result is always false and no new records are added.
Any suggestions for that?
__________________
Phyllis
pvmaddox is offline   Reply With Quote
Old 06-25-2009, 02:00 PM   Postid: 174886
pvmaddox
Registered User

Forum Notability:
0 pts: Even-handed
[Post Feedback]
 
Join Date: May 2007
Posts: 12
Re: My form variables don't work anymore

And how is that done?
__________________
Phyllis
pvmaddox is offline   Reply With Quote
Old 06-25-2009, 04:55 PM   Postid: 174887
jmihawkins
Registered User
 
jmihawkins's Avatar

Forum Notability:
124 pts: Helpful Contributor
[Post Feedback]
 
Join Date: May 2007
Location: Charlotte, NC, USA
Posts: 189
Re: My form variables don't work anymore

Kevin, fell out of my chair laughing so hard - printed the page, had to show it around some as explanation/example of my sense of humor (even tho I knew the comments would be unkind). Thankyou for lightening my day !!
__________________
Michael
jmihawkins is offline   Reply With Quote
Old 06-25-2009, 04:57 PM   Postid: 174888
 Kevin
Systems Administrator
 
Kevin's Avatar
 
Join Date: Aug 2001
Location: Orlando, FL
Posts: 2,481
Re: My form variables don't work anymore

To be fair, that was a cartoon from xkcd.com not something I made. It is one of their better ones though.
__________________
Kevin
Kevin is offline   Reply With Quote
Old 06-25-2009, 05:02 PM   Postid: 174889
kitchin
Site Owner

Forum Notability:
1163 pts: A True Crowd-pleaser!
[Post Feedback]
 
Join Date: Jan 2001
Location: Virginia
Posts: 2,992
Re: My form variables don't work anymore

The basic technique is described here:
http://us3.php.net/manual/en/functio...ape-string.php

I can't say it's always sufficient, but it is much better.
kitchin is offline   Reply With Quote
Old 06-25-2009, 07:11 PM   Postid: 174892
pvmaddox
Registered User

Forum Notability:
0 pts: Even-handed
[Post Feedback]
 
Join Date: May 2007
Posts: 12
Re: My form variables don't work anymore

Thanks.
__________________
Phyllis
pvmaddox is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 visitors)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

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


All times are GMT -4. The time now is 08:57 PM.


Running on vBulletin®
Copyright © 2000 - 2013, Jelsoft Enterprises Ltd.
Hosted & Administrated by FutureQuest, Inc.
Images & content copyright © 1998-2013 FutureQuest, Inc.
FutureQuest, Inc.