Current location: Hot Scripts Forums » Programming Languages » PHP » please help with parse error


please help with parse error

Reply
  #1 (permalink)  
Old 09-05-04, 11:14 PM
Mister B.'s Avatar
Mister B. Mister B. is offline
Wannabe Coder
 
Join Date: Jul 2003
Posts: 136
Thanks: 0
Thanked 0 Times in 0 Posts
Question 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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 09-06-04, 02:26 AM
<?Wille?> <?Wille?> is offline
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 09-06-04, 04:49 AM
NeverMind's Avatar
NeverMind NeverMind is offline
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]
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 09-06-04, 11:31 AM
infinitylimit's Avatar
infinitylimit infinitylimit is offline
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 09-08-04, 06:15 AM
NeverMind's Avatar
NeverMind NeverMind is offline
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]
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 09-08-04, 08:04 AM
Acecool's Avatar
Acecool Acecool is offline
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
__________________
Check Acecoolco.com for PHP Tutorials, and other tuts
If you plan on contacting me, please read this: Legal Terms & Conditions
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 09-08-04, 10:36 AM
infinitylimit's Avatar
infinitylimit infinitylimit is offline
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 09-08-04, 10:48 AM
NeverMind's Avatar
NeverMind NeverMind is offline
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]
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #9 (permalink)  
Old 09-08-04, 09:42 PM
Mister B.'s Avatar
Mister B. Mister B. is offline
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #10 (permalink)  
Old 09-09-04, 02:35 AM
blaw's Avatar
blaw blaw is offline
Junior Code Guru
 
Join Date: Dec 2003
Location: Vancouver, BC, Canada
Posts: 550
Thanks: 0
Thanked 0 Times in 0 Posts
Hello there,

Quote:
How is it insecure?
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:

PHP Code:

if ($_POST['sbtSubmit']) {

    if (!
get_magic_quotes_gpc()) {
        
$a_post array_map('addslashes'$_POST);
    }
    else {
        
$a_post $_POST;
    }

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 =|
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Parse error in php file sahil PHP 1 06-30-04 06:05 AM
Parse error: unexpected $ altlprsn PHP 3 05-25-04 01:59 AM
parse error help fraggle PHP 3 04-21-04 04:49 PM
parse error Abdul PHP 2 03-15-04 06:49 AM
[php error] parse error | fatal error xeoHosting PHP 1 01-03-04 09:12 PM


All times are GMT -5. The time now is 12:46 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.