Jump to content

Don't need a direct answer - just where to look for the error


boblan66

Recommended Posts

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]

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

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.

 

 

 

Link to comment
Share on other sites

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  :confused:

 

 

[attachment deleted by admin]

Link to comment
Share on other sites

<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.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.