boblan66 Posted November 28, 2010 Share Posted November 28, 2010 I just finished a page of code that passes all the debug tests except for the very last line on the page. </html>. The page has php and html, java script and some SQL. (see I'm learning and hadn't placed a post until I exhausted my limited resources. The Error Codeis: PHP Parse error: syntax error, unexpected $end in C:\wamp\www\registerform.php on line 292 Here's my concern: I read this error statement as an error()is missing. Please clarify something for me, You start the php code with <?php and end it with ?>. I also understand that the end() will stop all further operation. Correct. When you have a form call itself for data checking, and if the data is correct, send it to the appropriate database table, does one need to place the end() at the end of the php portion of the code? And if so, will it not stop any of the code from being read the first time the page is called? Also since the FORMs action calls for the page to load itself for data verification, how at the end of the checking do I go call another page? here's the page: The page is attached: [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/220042-dont-need-a-direct-answer-just-where-to-look-for-the-error/ Share on other sites More sharing options...
PFMaBiSmAd Posted November 28, 2010 Share Posted November 28, 2010 The error means that the php parser reached the end of your file while it was expecting a closing php element of some kind. This is usually due to a missing closing } but it can also be due to a missing closing quote or really any php statement that you have the opening syntax for but are missing the closing element. Quote Link to comment https://forums.phpfreaks.com/topic/220042-dont-need-a-direct-answer-just-where-to-look-for-the-error/#findComment-1140513 Share on other sites More sharing options...
harristweed Posted November 28, 2010 Share Posted November 28, 2010 errors in your code: Line 137 h1, { should be h1{ Line 170 should not have a '}' Line 140 need a closing ; "; You need three closing } after line 140 Quote Link to comment https://forums.phpfreaks.com/topic/220042-dont-need-a-direct-answer-just-where-to-look-for-the-error/#findComment-1140518 Share on other sites More sharing options...
boblan66 Posted November 28, 2010 Author Share Posted November 28, 2010 Thank you very much for your assistance. Again something simple to fix. I really appreciate your help. Bob Quote Link to comment https://forums.phpfreaks.com/topic/220042-dont-need-a-direct-answer-just-where-to-look-for-the-error/#findComment-1140535 Share on other sites More sharing options...
boblan66 Posted November 28, 2010 Author Share Posted November 28, 2010 I located the h1, and corrected it to read h1 {. line 140 is html and should not need closing }. I also fixed the missing } in that css element. I think I understand the use of {} Tell me if I'm correct! It signifies the start and end of a operation. What I'm confused with is the If else if and else. for example, $user1 = $name; if $user == !$user1; { echo "You are not Johm Smith!"; else if $user == $user1; ##Now do I place a { here, and if so after the next echo or just after the else statment? echo "Good Day John"; } Else $msg = "I do not know who you are. Get busy and learn this stuff!" echo $msg; } Is this correct use of ; and curly brackets? Maybe I'll get this through my thick head once and for all. Quote Link to comment https://forums.phpfreaks.com/topic/220042-dont-need-a-direct-answer-just-where-to-look-for-the-error/#findComment-1140540 Share on other sites More sharing options...
harristweed Posted November 28, 2010 Share Posted November 28, 2010 as last resort, rtfm http://cn.php.net/manual/en/control-structures.elseif.php Quote Link to comment https://forums.phpfreaks.com/topic/220042-dont-need-a-direct-answer-just-where-to-look-for-the-error/#findComment-1140541 Share on other sites More sharing options...
boblan66 Posted November 28, 2010 Author Share Posted November 28, 2010 I read the manual. However If you read my previous posts, the one reason I'm having so much trouble is that I have bad vision. Butr I did read the link you provided. Quote Link to comment https://forums.phpfreaks.com/topic/220042-dont-need-a-direct-answer-just-where-to-look-for-the-error/#findComment-1140712 Share on other sites More sharing options...
jcbones Posted November 29, 2010 Share Posted November 29, 2010 Do you still have questions on control structures? Quote Link to comment https://forums.phpfreaks.com/topic/220042-dont-need-a-direct-answer-just-where-to-look-for-the-error/#findComment-1140740 Share on other sites More sharing options...
boblan66 Posted November 30, 2010 Author Share Posted November 30, 2010 Yes, I must be slow. I have read and reread the section on controls, If's , loops etc. I think I got it, go to the code I sent as a attachment and still get the error. I somewhat embarrassed to ask for more help. I thought I'd go to another forum and ask. But I like this one. I know once I get one working correctly, I could build upon it. I look at the code and based upon what I think I'm reading, I figure I got it down, only to have that error show up again on the same line. At least I know that I'm missing a } or smi-colon. But where? Fully [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/220042-dont-need-a-direct-answer-just-where-to-look-for-the-error/#findComment-1141192 Share on other sites More sharing options...
JakeTheSnake3.0 Posted November 30, 2010 Share Posted November 30, 2010 <DOCTYPE html> should be <!DOCTYPE html> The last echo statement is missing a semicolon. Missing } bracket where "// } end of message" is. Missing } bracket where "// } Close else after missing vars check" is. Missing } bracket where "// }Close if $_POST" is. Those brackets should not be commented out. Also, a proactive solution to this kind of problem is to indent your code inside your IF statements. if (condition) { // code here } else { // code here if (anothercondition) { // code here } } Also, your long elseif structure for looking at missing information (user name, password, etc.) doesn't have to be like that....only if you want one error to show at a time. You can rewrite it to say: if(!$username) $errorMsg .= "--- User Name"; if(!$password) $errorMsg .= "--- password"; if(!$password2) $errorMsg .= "-- confirm your password"; It looks much easier to read that way, and instead of the user only being notified of one piece of missing information each time the form is submitted, they can see all of the info they missed. Quote Link to comment https://forums.phpfreaks.com/topic/220042-dont-need-a-direct-answer-just-where-to-look-for-the-error/#findComment-1141202 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.