dennismonsewicz Posted December 3, 2008 Share Posted December 3, 2008 can someone explain this error: Parse error: syntax error, unexpected T_SWITCH, expecting T_FUNCTION Quote Link to comment https://forums.phpfreaks.com/topic/135375-error-question/ Share on other sites More sharing options...
premiso Posted December 3, 2008 Share Posted December 3, 2008 Post the code and we can help you alot faster and more efficient. It seems like the program was expecting a function, not a switch. Chances are you are missing a } somewhere. Quote Link to comment https://forums.phpfreaks.com/topic/135375-error-question/#findComment-705121 Share on other sites More sharing options...
dennismonsewicz Posted December 3, 2008 Author Share Posted December 3, 2008 here is the function $d = $_GET['db']; class TableAttDeductible extends JTable { switch($d) { case "phoneplan": var $rowid = null; var $make = null; var $model = null; var $deductible = null; var $published = 0; break; case "plan_by_state": var $rowid = null; var $planid = null; var $planmakeid = null; var $planmodel = null; var $plantier = null; var $plandeductible = null; var $insurance_only_premium = null; var $insurance_warranty_premium = null; var $warranty_only_premium = null; var $published = 0; break; } function __construct(&$d) { parent::__construct( '#__' . $d, 'rowid', $d ); } } Quote Link to comment https://forums.phpfreaks.com/topic/135375-error-question/#findComment-705123 Share on other sites More sharing options...
premiso Posted December 3, 2008 Share Posted December 3, 2008 You need to define the variables outside of that switch then possible have a function and given what d is define them in that function. The function should probably be called within the constructor. But what you are trying to do is make the class have dynamic variables. I think you just need to write 2 separate classes, as I do not think that is "kosher" Quote Link to comment https://forums.phpfreaks.com/topic/135375-error-question/#findComment-705133 Share on other sites More sharing options...
dennismonsewicz Posted December 3, 2008 Author Share Posted December 3, 2008 ah gotcha... thanks for your help... I am pretty new to writing functions and classes. Quote Link to comment https://forums.phpfreaks.com/topic/135375-error-question/#findComment-705136 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.