Kestrad Posted December 14, 2009 Share Posted December 14, 2009 Hey all! I'm getting an unexpected T_VARIABLE with the following function: function getHighestParentName($id = $this->cid){ $cat = mysql_fetch_assoc(fsquery('getParentCategories', $id)); if ($cat['pid']!=0){getHighestParentName($cat['id']);} return $cat['name']; } fsquery is a function defined in another file, which I know is correctly defined and correctly referenced. pid, id, and name are column names in a mysql table. Can someone please help me find what's wrong? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/185042-unexpected-t_variable-error/ Share on other sites More sharing options...
KevinM1 Posted December 14, 2009 Share Posted December 14, 2009 Can you tell us which specific line is throwing the error? Quote Link to comment https://forums.phpfreaks.com/topic/185042-unexpected-t_variable-error/#findComment-976767 Share on other sites More sharing options...
rajivgonsalves Posted December 14, 2009 Share Posted December 14, 2009 you cannot do this $id = $this->cid, assign the default as another variable it should be something like $id = '' Quote Link to comment https://forums.phpfreaks.com/topic/185042-unexpected-t_variable-error/#findComment-976774 Share on other sites More sharing options...
Kestrad Posted December 14, 2009 Author Share Posted December 14, 2009 Sorry, I don't quite understand--do you mean that I can't define $id as another variable that already exists? Quote Link to comment https://forums.phpfreaks.com/topic/185042-unexpected-t_variable-error/#findComment-977137 Share on other sites More sharing options...
mrMarcus Posted December 14, 2009 Share Posted December 14, 2009 could yo not just do this: <?php function getHighestParentName (){ $cat = mysql_fetch_assoc(fsquery('getParentCategories', $this->cid)); if ($cat['pid']!=0){getHighestParentName($cat['id']);} return $cat['name']; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/185042-unexpected-t_variable-error/#findComment-977141 Share on other sites More sharing options...
Kestrad Posted December 14, 2009 Author Share Posted December 14, 2009 If the function doesn't take an argument, doesn't that mean I can't pass it one? Quote Link to comment https://forums.phpfreaks.com/topic/185042-unexpected-t_variable-error/#findComment-977151 Share on other sites More sharing options...
mrMarcus Posted December 14, 2009 Share Posted December 14, 2009 did you try it? seems you may be wandering into unknown territories with OOP here. Quote Link to comment https://forums.phpfreaks.com/topic/185042-unexpected-t_variable-error/#findComment-977153 Share on other sites More sharing options...
Kestrad Posted December 14, 2009 Author Share Posted December 14, 2009 Yep. I'm not getting the error anymore! Thanks for your help! Quote Link to comment https://forums.phpfreaks.com/topic/185042-unexpected-t_variable-error/#findComment-977155 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.