Page 1 of 1

Parse error: syntax error

Posted: Tue Nov 17, 2009 2:52 pm
by peterspliid
Well first of all, first post :D Joined because I have a PHP error I simply have no idea how to solve. The script is for an application form for my forum, where people can apply to join us. Here is the whole php script.

Code: Select all

<?php
/**
* @package application.php
* @copyright (c) JimA http://beta-garden.com 2009
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
 
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
 
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('mods/application');
 
// You need to login before being able to send out an application
if ($user->data['user_id'] == ANONYMOUS)
{
    login_box('', $user->lang['LOGIN_APPLICATION_FORM']);
}
 
include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
 
// Let's set the configuration, this is the ID of the forum where the post goes to
$forumid_send = 2;
 
$submit = (isset($_POST['submit'])) ? true : false;
 
    if ($submit)
    {
 
// Setting the variables we need to submit the post to the forum where all the applications come in
$apply_subject  = sprintf($user->lang['APPLICATION_SUBJECT'], $user->data['username']);
$apply_post     = sprintf($user->lang['APPLICATION_MESSAGE'], $user->data['username'], utf8_normalize_nfc(request_var('name', '', true)), $user->data['user_email'], request_var('postion', '', true), utf8_normalize_nfc(request_var('why', '', true))), request_var('name', '', true), request_var('class', '', true), request_var('race', '', true), request_var('mainspec', '', true), request_var('offspec', '', true), request_var('equipment', '', true), request_var('progress', '', true), request_var('howoften', '', true), request_var('prevguilds', '', true), request_var('vent', '', true), request_var('charhis', '', true), request_var('seek', '', true), request_var('benifit', '', true), request_var('recommend', '', true), request_var('rules', '', true), request_var('question', '', true), request_var('raidtimes', '', true), request_var('dwarves', '', true), request_var('realname', '', true), request_var('age', '', true), request_var('location', '', true), request_var('occupation', '', true), request_var('describe', '', true);
 
// variables to hold the parameters for submit_post
$poll = $uid = $bitfield = $options = ''; 
 
generate_text_for_storage($apply_post, $uid, $bitfield, $options, true, true, true);
 
$data = array( 
    'forum_id'      => $forumid_send,
    'icon_id'       => false,
 
    'enable_bbcode'     => true,
    'enable_smilies'    => true,
    'enable_urls'       => true,
    'enable_sig'        => true,
 
    'message'       => $apply_post,
    'message_md5'   => md5($apply_post),
                
    'bbcode_bitfield'   => $bitfield,
    'bbcode_uid'        => $uid,
 
    'post_edit_locked'  => 0,
    'topic_title'       => $apply_subject,
    'notify_set'        => false,
    'notify'            => false,
    'post_time'         => 0,
    'forum_name'        => '',
    'enable_indexing'   => true,
);
 
// Sending the post to the forum set in configuration above
submit_post('post', $apply_subject, '', POST_NORMAL, $poll, $data);
 
$message = $user->lang['APPLICATION_SEND'];
$message = $message . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a>');
trigger_error($message);
}
 
page_header($user->lang['APPLICATION_PAGETITLE']);
 
$template->assign_vars(array(
    'PROCESS_APPFORM'   => append_sid("{$phpbb_root_path}application.$phpEx"),
    ));
    
$template->set_filenames(array(
    'body' => 'appform_body.html',
));
 
page_footer();
 
?>
The error is in line 37, which is this:

Code: Select all

$apply_post     = sprintf($user->lang['APPLICATION_MESSAGE'], $user->data['username'], utf8_normalize_nfc(request_var('name', '', true)), $user->data['user_email'], request_var('postion', '', true), utf8_normalize_nfc(request_var('why', '', true))), request_var('name', '', true), request_var('class', '', true), request_var('race', '', true), request_var('mainspec', '', true), request_var('offspec', '', true), request_var('equipment', '', true), request_var('progress', '', true), request_var('howoften', '', true), request_var('prevguilds', '', true), request_var('vent', '', true), request_var('charhis', '', true), request_var('seek', '', true), request_var('benifit', '', true), request_var('recommend', '', true), request_var('rules', '', true), request_var('question', '', true), request_var('raidtimes', '', true), request_var('dwarves', '', true), request_var('realname', '', true), request_var('age', '', true), request_var('location', '', true), request_var('occupation', '', true), request_var('describe', '', true);
I would be very happy if someone could solve it :)

EDIT: The error is "Parse error: syntax error, unexpected ',' in */application.php on line 37"

Re: Parse error: syntax error

Posted: Tue Nov 17, 2009 2:58 pm
by iankent
this bit I think has an extra )
utf8_normalize_nfc(request_var('why', '', true)))
should be
utf8_normalize_nfc(request_var('why', '', true))

the extra bracket means php is expecting a ; or operator (+ . - etc) rather than a comma

hth

p.s. it'd be much easier to spot problems like this if you break it down a bit rather than putting everything on one line :) doesn't affect the code but does make it more human-readable

p.p.s - forgot to say, welcome to the forum :)

Re: Parse error: syntax error

Posted: Tue Nov 17, 2009 3:08 pm
by peterspliid
Thank you, didn't notice. Now it seems to give me a new error, very similar to the first:
Parse error: syntax error, unexpected ';' in */application.php on line 37

Note it changed from ',' to ';'

The line now looks like this:

Code: Select all

$apply_post     = sprintf($user->lang['APPLICATION_MESSAGE'], $user->data['username'], utf8_normalize_nfc(request_var('name', '', true)), $user->data['user_email'], request_var('postion', '', true), utf8_normalize_nfc(request_var('why', '', true)), request_var('name', '', true), request_var('class', '', true), request_var('race', '', true), request_var('mainspec', '', true), request_var('offspec', '', true), request_var('equipment', '', true), request_var('progress', '', true), request_var('howoften', '', true), request_var('prevguilds', '', true), request_var('vent', '', true), request_var('charhis', '', true), request_var('seek', '', true), request_var('benifit', '', true), request_var('recommend', '', true), request_var('rules', '', true), request_var('question', '', true), request_var('raidtimes', '', true), request_var('dwarves', '', true), request_var('realname', '', true), request_var('age', '', true), request_var('location', '', true), request_var('occupation', '', true), request_var('describe', '', true);
And sorry for the messed bunch of code. Might clean it while waiting ;)

Really appreciated.

Re: Parse error: syntax error

Posted: Tue Nov 17, 2009 3:12 pm
by iankent
You're missing a ) at the end :)

i.e., the last bit should be )); not );

Re: Parse error: syntax error

Posted: Tue Nov 17, 2009 3:20 pm
by peterspliid
Works again! Thank you so much :drunk: