monkeytooth Posted March 1, 2011 Share Posted March 1, 2011 Hey People, Im stuck right now and I need some fresh eyes. Seems this functions someone made that I gotta fix is broken Im assuming maybe a missing bracket or one out of place.. but.. Im not seeing it, ive been staring at it for far to long tryin to fix it find the issue etc.. and its eluding me. Right now the error I am getting is "unexpected $end" heres the function function getlinkedinstoredContacts($user_id,$limit=10,$offset=1){ $query = $this->db->get_where('cm_user_linkedin_contacts', array('user_id' => $user_id,'same_company'=>'Y'),$limit,$offset); if ($query->num_rows() > 0){ $contacts = $query->result(); //Loop throught the contact list foreach ($contacts as $key => $contact){ $headline = $contact->headline; if (preg_match('/(at )| @ /', $headline)){$arr = preg_split('/(at )| @ /', $headline, 2);} elseif (preg_match('/,/', $headline)){$arr = preg_split('/,/', $headline, 2);} else{$arr[0] = $headline;$arr[1] = '';} $arr[0] = preg_replace('/^\s*/', '', $arr[0]); $arr[0] = preg_replace('/\s*$/', '', $arr[0]); $arr[1] = preg_replace('/^\s*/', '', $arr[1]); $arr[1] = preg_replace('/\s*$/', '', $arr[1]); $current_company_position = $arr[0]; // job_title $current_company_name=$arr[1]; //company //for testing if ($counter > 21){unset($contacts[$key]);} else{ $contact->job_title=$current_company_position; $contact->current_company=$current_company_name; if ($contact->picture_url == ''){ $contact->picture_url = $this->config->item('base_url') . "static/images/avatar-large.jpg')"; $contacts[$key]=$contact; $counter++; } } return $contacts; } return null; } Quote Link to comment https://forums.phpfreaks.com/topic/229240-stuck-with-a-broken-functions-cant-figure-it-out/ Share on other sites More sharing options...
monkeytooth Posted March 1, 2011 Author Share Posted March 1, 2011 Just one of them days I suppose. Still bangin my head against the keys on this one. I just don't get it.. And Ill bet above anything else that my issue with this is something so small, so stupid.. and I'm just not seeing it. Quote Link to comment https://forums.phpfreaks.com/topic/229240-stuck-with-a-broken-functions-cant-figure-it-out/#findComment-1181235 Share on other sites More sharing options...
ccmcs Posted March 1, 2011 Share Posted March 1, 2011 are all your strings setup above the bit you pasted in? $user_id etc Quote Link to comment https://forums.phpfreaks.com/topic/229240-stuck-with-a-broken-functions-cant-figure-it-out/#findComment-1181247 Share on other sites More sharing options...
monkeytooth Posted March 1, 2011 Author Share Posted March 1, 2011 When making a call to it, yes.. But Ive isolated the entire function in an otherwise empty php file. just to see if it would give me an error, and what error that might be, and its unexpected $end the only thing I can think of is a broken bracket, parenthesis or something to the effect there of, however I am just not seeing it for the life of me, and all in all it seems like the function from inspecting visually its all in place. Quote Link to comment https://forums.phpfreaks.com/topic/229240-stuck-with-a-broken-functions-cant-figure-it-out/#findComment-1181267 Share on other sites More sharing options...
monkeytooth Posted March 1, 2011 Author Share Posted March 1, 2011 :'( Im just convinced everything on this project I am working on just hates me. Its one ghost bug after the other after the other. None of its my code originally, and working with it has been a nightmare.. unfortunatly theres not much I can do at the current time to improve on it much to make it better, im stuck making due with what I have to work with. Quote Link to comment https://forums.phpfreaks.com/topic/229240-stuck-with-a-broken-functions-cant-figure-it-out/#findComment-1181270 Share on other sites More sharing options...
KevinM1 Posted March 1, 2011 Share Posted March 1, 2011 You're missing the ending bracket. Your last bracket closes if ($query->num_rows() > 0) Quote Link to comment https://forums.phpfreaks.com/topic/229240-stuck-with-a-broken-functions-cant-figure-it-out/#findComment-1181272 Share on other sites More sharing options...
monkeytooth Posted March 1, 2011 Author Share Posted March 1, 2011 HAH wow, thats what I said, something entierly stupid somewhere that I am missing.. son of a bish, you know how many hours i spent lookin at that thing going over and over it and I still managed to miss that.. damn man.. thank you though for pointing it out.. Quote Link to comment https://forums.phpfreaks.com/topic/229240-stuck-with-a-broken-functions-cant-figure-it-out/#findComment-1181293 Share on other sites More sharing options...
KevinM1 Posted March 1, 2011 Share Posted March 1, 2011 You should get yourself an editor that highlights/aligns matching braces. You should also work at consistency with your formatting (newlines, indents, etc.). I use Notepad++ for my PHP work. Quote Link to comment https://forums.phpfreaks.com/topic/229240-stuck-with-a-broken-functions-cant-figure-it-out/#findComment-1181301 Share on other sites More sharing options...
monkeytooth Posted March 1, 2011 Author Share Posted March 1, 2011 you know I keep hearing about this NotePad++ lately known about it for a long time, I think your right might be time for a change Quote Link to comment https://forums.phpfreaks.com/topic/229240-stuck-with-a-broken-functions-cant-figure-it-out/#findComment-1181318 Share on other sites More sharing options...
ccmcs Posted March 1, 2011 Share Posted March 1, 2011 is dreamweaver a swear word around here? That highlights everything nicely... (awaits possible backlash?!) Quote Link to comment https://forums.phpfreaks.com/topic/229240-stuck-with-a-broken-functions-cant-figure-it-out/#findComment-1181495 Share on other sites More sharing options...
jasonrichardsmith Posted March 1, 2011 Share Posted March 1, 2011 Geany is an excellent cross platform open source editor. http://www.geany.org/Documentation/Screenshots Quote Link to comment https://forums.phpfreaks.com/topic/229240-stuck-with-a-broken-functions-cant-figure-it-out/#findComment-1181522 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.