Problem with code

The full code is here: http://pastebin.com/yXrWVxmH.

To make it easy on you, the error is: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION in your code on line 99.

I guess I forgot to put a “;” sign somewhere but I just can’t find it.
The rest of the code seems fine to me.

A little help, please?

Well, actually, you have dozens of syntax errors in this code. Some of these actually work for you because they are archival versions of today’s PHP syntax. I would suggest you fix these to be more standard. The reason this is important is for others who must view your code. (Not really for your own use!) So, I will cover each error and explain each. (Some are duplicates.)

First, when using an “IF” clause, you really need to use the braces. { } It makes IF’s so much easier to read and is the current standard. So, an IF clause like this:
If (A==B)
echo “same”;
else
echo “different”;
Will work and execute correctly. But, the syntax is not correct for current standards. It would be like this:
if (A==B) {
echo “same”;
}else{
echo “different”;
}
Now, I realize this is a small difference in this example, but, when you get a large number of nested IF clauses, it is much more readable. Normally most programmers will indent the IF’s and so if an second IF is inside another, they are indented further. This make it much easier for someone else to read.

Next, in your “register-now” function, you never close the function. This can cause a lot of problems and errors that may not show up till later in the code. My guess is that this is your main error. You need to add a “}” in line 25.

Normally, it good structured programming code, you place ALL of your functions at the top of the class and then any actual code is after those functions. You have a lose line of code at line 41. Okay, after reading the entire code, I see where you create classes and several function in these classes. But, the functions are only used one time, hence the odd code between each function. You should study up on functions. They are usually only created if they are needed more than once and quite often are passed options or arguments. It is a waste of code to create one, use it once and then never call it again. So, most of your functions should just be straight code instead.

Now, counting all of the braces you used, “{” “}”, I found that line 94 and 95 are not needed. They do not match up with starting braces anywhere…

Your “login” class has code, then functions, then more code. Again, in a class it is best to place all of your function at the top of the class and then the code and the code that calls the functions…
This “loginnow” function does not end. Line 114 should be a “}”.

Line 148 is an extra “}” and should be deleted…

Line 157 is an extra “}” and should be deleted…

Well, so yes, you were right! You had a missing brace and a few extras… And, a few syntax issues…
But, basically all else seems to look good although I did not test it live.

Good luck, hope this helps. Let us know if you solve it…

The function registerNow() contains other functions in it!
It ends in line 95.
The class “register” closes in line 96.

Same thing about the long function loginNow(), it ends in line 148. The class “login” ends in line 157.

About the functions, they are sometimes made to organize the PHP page.
Otherwise, my code would have looked even more difficult to read and understand.

After I cleared some things up, can you read it again and tell me what should I do about the code?

Well, I asked a few other programmers about placing functions inside of functions. We all agree that there is no reason to ever do that. Since PHP code is string based, when a function is called, the PHP code will research for it. It basically just makes it harder to read. If you are trying to make it harder to read, then okay. Otherwise, the 4 or 5 that I asked about this agree with me that it makes no sense to nest functions.

Now, overall, your code looks simple enough. Is your error still in line 99? Is it the same error as before?

Here’s the new code: http://pastebin.com/1p8p5XXq.
I fixed that function thing and the if…else statements.

NOW the error is: syntax error, unexpected T_IF, expecting T_FUNCTION in your code on line 18

So now, it says a function is needed there, so I am very confused.

See, I want the code to work only if the user pressed the submit button.

Hello?

Sponsor our Newsletter | Privacy Policy | Terms of Service