twidlar Posted May 11, 2011 Share Posted May 11, 2011 This is absolutely stupid. I'm debugging PHP in Eclipse PDT with XDebug and XAMPP on Windows 7. A section of code has been working for weeks. Suddenly I'm told the following is a syntax error (line 226) $forumtitle = $forum['title']; $threadtitle = $thread['title']; Eclipse matches bracket and normally clipse would highlight [ when I put the cursor behind ]. Not here. On similar statements before this I changed ' (single quote) to (double quote)". The brackets [ and ] highlighted correctly but the " produced a louder syntax error.. Then I simply removed the single quotes. No syntax error. Brackets match. But I will probably get a syntax error. Usually stupidity like this indicates a quote problem somewhere before this code. After looking very hard, I see none. It feels like something is wrong with the Eclipse editor and something has to be reset. But what? I would appreciate any help. Quote Link to comment https://forums.phpfreaks.com/topic/236054-crazy-simple-syntax-error/ Share on other sites More sharing options...
cssfreakie Posted May 11, 2011 Share Posted May 11, 2011 just a guess since it seems valid, retype the single quotes. Quote Link to comment https://forums.phpfreaks.com/topic/236054-crazy-simple-syntax-error/#findComment-1213526 Share on other sites More sharing options...
twidlar Posted May 11, 2011 Author Share Posted May 11, 2011 Thanks. I have retyped them a few different ways to no effect. I'm going to try some ideas tomorrow. I will let you know. Quote Link to comment https://forums.phpfreaks.com/topic/236054-crazy-simple-syntax-error/#findComment-1213582 Share on other sites More sharing options...
PFMaBiSmAd Posted May 11, 2011 Share Posted May 11, 2011 Syntax errors are usually reported on a line after where the actual problem is at (i.e. the parser doesn't know that you didn't intend to leave out that punctuation that made all the following lines part of a statement x lines before where it found something it could not understand in your code.) A) Post the exact error message (xxxxx out any information you don't want to show). B) Post at least 10 lines before and including the line where the error is reported. Quote Link to comment https://forums.phpfreaks.com/topic/236054-crazy-simple-syntax-error/#findComment-1213587 Share on other sites More sharing options...
twidlar Posted May 11, 2011 Author Share Posted May 11, 2011 Thanks. As you suggested, here is some code. I went back further than 10 lines. function getperm($poster) { global $forum; global $forumbody; $user = $forum[user]; if ($poster == $user) return('O'); extract($forumbody[adm]); if (inlist($poster,$hosts)) return('H'); if (inlist($poster,$participants)) return('M'); if (inlist($poster,$moderated)) return('W'); if (inlist($poster,$readonly)) return('R'); return('G'); } // FIND no IN threadbody[no] function postindex($no) { global $threadbody; $nums = $threadbody[posts][no]; if (empty($nums)) return(FALSE); $i = array_search($no,$nums); // SHOULD BE IN ARRAY if ($i !== FALSE) return($i); for ($i=0,$n=count($nums),$k=FALSE; ($i < $n); $i++) if ($no >= $nums[$i]) // SHOULDN'T FIND EQUAL { $k = $i; break; } // FIND CLOSE return($k); } // TOOLBAR FOR POST PAGES function mkposttoolbar($where='B') // Top/Bottom ASSUME Bottom { global $forumid, $forum, $forumbody; global $threadid, $thread; global $reader; global $sub; global $yourforums; $forumtitle = $forum['title']; $threadtitle = $thread['title']; $readername = ['user']; @extract($forumbody['adm']); if (!$toolbarColor) $toolbarColor = '#EEEEEE'; $id = ($threadid) ? $threadid : $forumid; The 5th line {$user = $forum[user];} used to be {$user = $forum['user'];} producing the same error; Line 226 {$forumtitle = $forum['title'];} (6th from bottom) produces the error -- ( ! ) Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in D:\xampp\htdocs\econcurrent.com\wx\webx\showposts.php on line 226 ==== What makes me think the problem is Eclipse and not PHP is that I had a incident a week ago with another module involving single quotes. I had record arrays like $wx = array('id' => $id, 'cd' => 'P', 'user' => $user, ....... ); One of these keys all of a sudden showed up as 'user not 'user'. I tried to add the ' and it wouldn't take it or any other character. Stuff before and after it could be changed. I discovered the module which was about 6K was now 168K. I cut and pasted the code to EditPad Lite and discovered big chunks of whitespace had been added. I got rid of that and cut and pasted that back to Eclipse and all was OK. I have developed some code that worked fine. A week ago it stopped working right after Firefox updated itself. Now XDebug doesn't go from page to page properly and variables don't show. And I have been having strange problems that look like PHP problems but I don't think are. I am going to have to tear the code apart into small test cases to isolate this nonsense. Quote Link to comment https://forums.phpfreaks.com/topic/236054-crazy-simple-syntax-error/#findComment-1213812 Share on other sites More sharing options...
PFMaBiSmAd Posted May 11, 2011 Share Posted May 11, 2011 The only parse error in the posted code is in this line - $readername = ['user']; (missing the array variable in front of the ['user'] ) I would say your development system/editor has a bug/virus that is corrupting the files. Quote Link to comment https://forums.phpfreaks.com/topic/236054-crazy-simple-syntax-error/#findComment-1213841 Share on other sites More sharing options...
twidlar Posted May 11, 2011 Author Share Posted May 11, 2011 Duh. I missed that completely. Thanks. I fixed it. Line 226 {$forumtitle = $forum['title'];} remains an error! Note that in the two functions above that mkposttoolbar() function, I got rid of the error by removing the single quotes in 183: $user = $forum[user]; 186: extract($forumbody[adm]); 204: $nums = $threadbody[posts][no]; I expect warnings when I try to execute tem. All this seemed to start after Firefox updated itself. last Thursday. XDebug ad trouble debugging page to page and showing variables. Eclipse became strange. Is Windows7 part of the problem?/ So maybe I should resinstall or upgrade to current versions. I need to see if this error shows up in my 3 different situations. 1. Debug with Eclipse and XDebug. 2. Run it under XAMPP. 3. Run it on the host under Linux. Quote Link to comment https://forums.phpfreaks.com/topic/236054-crazy-simple-syntax-error/#findComment-1214052 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.