please help with parse error
09-05-04, 11:14 PM
Wannabe Coder
Join Date: Jul 2003
Posts: 136
Thanks: 0
Thanked 0 Times in 0 Posts
please help with parse error
Parse error: parse error in /home/chaotice/public_html/signupresponse.php on line 6
PHP Code:
mysql_query ( "INSERT INTO structure (usanameish, usapassish, usaemailish, usamsnish, usaaimish, usahooish, usaallowemailish) VALUES ( { $_POST [ 'usernamer' ]} , { $_POST [ 'userpasser' ]} , { $_POST [ 'useremailer' ]} , { $_POST [ 'usermsner' ]} , { $_POST [ 'useraimer' ]} , { $_POST [ 'useryahooer' ]} , { $_POST [ 'allow' ]} )" ;
Brain explode
__________________
God save us from the religious fanatics
09-06-04, 02:26 AM
Junior Code Guru
Join Date: Jan 2004
Location: Helsinki, Finland
Posts: 666
Thanks: 0
Thanked 0 Times in 0 Posts
try this.. with quotes around the values
PHP Code:
mysql_query ( "INSERT INTO structure (usanameish, usapassish, usaemailish, usamsnish, usaaimish, usahooish, usaallowemailish) VALUES (' { $_POST [ 'usernamer' ]} ', ' { $_POST [ 'userpasser' ]} ', ' { $_POST [ 'useremailer' ]} ', ' { $_POST [ 'usermsner' ]} ', ' { $_POST [ 'useraimer' ]} ', ' { $_POST [ 'useryahooer' ]} ', ' { $_POST [ 'allow' ]} ')" ;
hope it helps
Wille
09-06-04, 04:49 AM
Community VIP
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
what <?Wille?> said and you forgot to close the "(" after the function call ..
so use this:
PHP Code:
mysql_query ( "INSERT INTO structure (usanameish, usapassish, usaemailish, usamsnish, usaaimish, usahooish, usaallowemailish) VALUES (' { $_POST [ 'usernamer' ]} ', ' { $_POST [ 'userpasser' ]} ', ' { $_POST [ 'useremailer' ]} ', ' { $_POST [ 'usermsner' ]} ', ' { $_POST [ 'useraimer' ]} ', ' { $_POST [ 'useryahooer' ]} ', ' { $_POST [ 'allow' ]} ')" );
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9 ]
09-06-04, 11:31 AM
Code Guru
Join Date: Jun 2004
Location: Oregon
Posts: 758
Thanks: 0
Thanked 0 Times in 0 Posts
I always have to have single quotes around the fieldnames also, that is how PMA does it.
PHP Code:
mysql_query ( "INSERT INTO structure ('usanameish', 'usapassish', 'usaemailish', 'usamsnish', 'usaaimish', 'usahooish', 'usaallowemailish') VALUES (' { $_POST [ 'usernamer' ]} ', ' { $_POST [ 'userpasser' ]} ', ' { $_POST [ 'useremailer' ]} ', ' { $_POST [ 'usermsner' ]} ', ' { $_POST [ 'useraimer' ]} ', ' { $_POST [ 'useryahooer' ]} ', ' { $_POST [ 'allow' ]} ')" );
weird field names
__________________
Hawk Enterprises -- Home to PHP games, open-source code, tutorials and free downloads
09-08-04, 06:15 AM
Community VIP
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
Quote:
Originally Posted by infinitylimit
I always have to have single quotes around the fieldnames also, that is how PMA does it.
PHP Code:
mysql_query ( "INSERT INTO structure ('usanameish', 'usapassish', 'usaemailish', 'usamsnish', 'usaaimish', 'usahooish', 'usaallowemailish') VALUES (' { $_POST [ 'usernamer' ]} ', ' { $_POST [ 'userpasser' ]} ', ' { $_POST [ 'useremailer' ]} ', ' { $_POST [ 'usermsner' ]} ', ' { $_POST [ 'useraimer' ]} ', ' { $_POST [ 'useryahooer' ]} ', ' { $_POST [ 'allow' ]} ')" );
weird field names
PMA uses back quotes ` not '
running your query will generate an error ..
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9 ]
09-08-04, 08:04 AM
Aspiring Coder
Join Date: Nov 2003
Posts: 506
Thanks: 0
Thanked 0 Times in 0 Posts
Hey, I feel that using the set method is better.
$Query = "INSERT INTO structure SET usanameish='" . $_POST['blah'] . "', usapassish='" . $_POST['blahblahblah'] . "', and='so on'";
mysql_query($Query);
BUT, putting information directly from the form to your database is INSECURE
09-08-04, 10:36 AM
Code Guru
Join Date: Jun 2004
Location: Oregon
Posts: 758
Thanks: 0
Thanked 0 Times in 0 Posts
Nevermind, you are correct my mistake. ` backquotes it is.
__________________
Hawk Enterprises -- Home to PHP games, open-source code, tutorials and free downloads
09-08-04, 10:48 AM
Community VIP
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
we all do mistakes
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9 ]
09-08-04, 09:42 PM
Wannabe Coder
Join Date: Jul 2003
Posts: 136
Thanks: 0
Thanked 0 Times in 0 Posts
How is it insecure? How can I make it more secure?
__________________
God save us from the religious fanatics
09-09-04, 02:35 AM
Junior Code Guru
Join Date: Dec 2003
Location: Vancouver, BC, Canada
Posts: 550
Thanks: 0
Thanked 0 Times in 0 Posts
Hello there,
For one, if a user entered troublesome characters like single quote without escaping, whatever database operation you are trying to do will fail, which could cause unexpected problems.
Another thing is that if this is for something like forum scripts like this one where the user input will be displayed to the public, you should pay attention to malicious codes. For instance, adding <pre> or something would make your site look really ugly. Worse, if someone tries inserting malicious javascript, your site could become a gateway to information theft, etc (you can see <pre>'s < and > got escaped with htmlentities()) or something in here).
Quote:
How can I make it more secure?
At the very least, you should escape the troublesome characters in the data input with addslashes(). If, however, your php's magic_quotes_gpc is true, then GET, POST, and COOKIE will be automatically addslashes()-ed, so do not worry about this or you would be adding two more unnecessary slashes. Nevertheless, just because it is true today doesn't mean it will stay the same tomorrow - especially if you are staying with a shared host, so check this value first with get_magic_quotes_gpc().
Simple example would be:
The above will get all your POSTed values into $a_post, addslashes()-ed. You can come up with your own, depending on your script's needs.
Good luck!
__________________
Blavv =|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools
Display Modes
Linear Mode
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off