Dismiss
Announcing Stack Overflow Documentation

We started with Q&A. Technical documentation is next, and we need your help.

Whether you're a beginner or an experienced developer, you can contribute.

Sign up and start helping → Learn more about Documentation →

Hi this is my first post on here so any response would be greatly appreciated. I'm working on a complex php form and keeping getting this error when I click the submit button "Parse error: syntax error, unexpected T_VARIABLE in /weburl/process_form.php on line 3" line 3 is "$form = new ProcessForm();" and just to give you an idea the code that follows is "

$form->field_rules = array(
    'fullname'=>'required',
    'dob'=>'required',
    'nin'=>'required',
    'agency'=>'required',
    'contactno'=>'required',
    'weekending'=>'required',
    'journeydetails'=>'required',
    'mileage'=>'required',
    'publictransport'=>'required',
    'totalamount'=>'required',
    'safetyequipment'=>'required',
    'totalamount2'=>'required',
    'contracttickbox'=>'required',
);"

I've been working on this all day and cannot understand why I'm getting this error.

share|improve this question

closed as too localized by mario, animuson, Kev Mar 3 '13 at 1:08

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

    
The actual error always precedes the mentioned line number. – mario Mar 2 '13 at 20:23
    
its probably a missing semi colon on the line before – JamesHalsall Mar 2 '13 at 20:24
up vote 0 down vote accepted

Two problems:

First omit the last "," in array. Second omit the " at the end.

$form->field_rules = array( 'fullname'=>'required', 'dob'=>'required', 'nin'=>'required', 'agency'=>'required', 'contactno'=>'required', 'weekending'=>'required', 'journeydetails'=>'required', 'mileage'=>'required', 'publictransport'=>'required', 'totalamount'=>'required', 'safetyequipment'=>'required', 'totalamount2'=>'required', 'contracttickbox'=>'required' );

share|improve this answer

This );" should not have the quote. i.e. );

share|improve this answer

You have an additional comma and an extra double quote. Remove them.

'contracttickbox'=>'required',
                           --^
);"
--^
share|improve this answer

will work perfectly....

$form->field_rules = array(
    'fullname'=>'required',
    'dob'=>'required',
    'nin'=>'required',
    'agency'=>'required',
    'contactno'=>'required',
    'weekending'=>'required',
    'journeydetails'=>'required',
    'mileage'=>'required',
    'publictransport'=>'required',
    'totalamount'=>'required',
    'safetyequipment'=>'required',
    'totalamount2'=>'required',
    'contracttickbox'=>'required'
);
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.