How JustAnswer Works:
  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site. Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.
Ask TheDoctor Your Own Question
TheDoctor, Professional w/Adv. Degree
Category: Homework
Satisfied Customers: 1757
Experience:  M.S. in Internet Information Systems
Type Your Homework Question Here...
TheDoctor is online now
A new question is answered every 9 seconds

**For TheDoctor** I have a question for you if you can this

This answer was rated:

**For TheDoctor**
I have a question for you if you can this answer me. I will send the question.
Hello again! Thank you for requesting me.

Please send me the details. If you have any documents to share, you can upload them to

Once uploaded, you will be given a link on the right. Click on the 'Copy Link' option and then paste it here.

Thank you
Customer: replied 4 years ago.
Customer: replied 4 years ago.

Parse error: syntax error, unexpected $end in /home/ic/Customer/public_html/215/m3/controller/register.php on line 196


in register.php

And could convert everything to PDO instead of mysql


Hello again,

We have a few different issues. First, you cannot send me three PHP files and not include files that are required by these files. See these lines?

//connect to the database so we can check, edit, or insert data to our users table
include '../model/connect.php';

//include out functions file giving us access to the protect() function made earlier
include "../includes/functions.php";

Without connect.php, both of the content files will have a fatal error. Additionally, I need the database that this refers to or I cannot work with the pages.

Please send me the intact site content, along with connect.php, and an export file for the database.

Thank you
Customer: replied 4 years ago.

I already sent the functions file the db info is in the connect.php file.

The connect.php only has a connect. On my computer, that would connect to absolutely nothing and cause a fatal error, still preventing me from assisting you.

I need the actual database that way my system does not throw a fatal error. That is why I asked for an export file.

Go to phpMyAdmin. Select the Database. Select Export. Export the Database. Send me the resulting file.

Thank you
Customer: replied 4 years ago.

I wasn't sure how you wanted the export I did excel and sql

It appears that you exported your MySQL installation (information_schema) rather than the database for this project (m3). You need to select the database first (m3), and then go to export.
Customer: replied 4 years ago.

Hello again,

I am currently fixing this page. I will contact you when it is ready.
Customer: replied 4 years ago.

Thanks Doc

Hello again!

I have corrected the errors. You can download the two files here:


I fixed the parse error as well as the queries. I'm not sure why you were creating a PDO object and then not using it. Please note that the old mysql api (e.g., mysql_query) is deprecated and is scheduled to be removed from the language altogether.

Also, in your activate page, there was no need to loop through all records in the user table. MySQL has a built-in SHA1 function. So you do not need to go through and check every record. As you will see, I have turned your code into a single query and significantly reduced the required coding.

Let me know if you have any questions. I'm here to help.

Please remember to rate my answer. Thank you so much and have a wonderful day!
Customer: replied 4 years ago.

I want the queries to be in PDO. I just didn't know how to do it. Will you do it?


You need to spend $3 to view this post. Add Funds to your account and buy credits.
TheDoctor and 2 other Homework Specialists are ready to help you
Customer: replied 4 years ago.

**For TheDoctor**

I am still getting parse errors on line 137 I think there were too many "}"'s but if I take out one I get:

Parse error: syntax error, unexpected $end in /home/ic/Customer/public_html/215/m3/controller/register.php on line 222


Could you look into this hopefully before 5:00 PST but if not asap Thanks


If you are getting a parse error, then you changed something. Especially considering that in the code that I sent you, line 137 has nothing on it that could produce a parse error. The code I sent you has absolutely no parse errors.

Please zip up the files that you have right now and send them to me so that I can see what you changed.


Thank you

Customer: replied 4 years ago.

**For TheDoctor**


it is line 137 from functions.php file:


135 function user_active($username) {
136 $username = sanitize($username);
137 return (mysql_result(mysql_query))

I want to pass a 1 to active field in the user table so that a person cannot logon unless they activate their account by email. Could help with this function and make it PDO

In the code that you sent me and I sent back to you, you were not using user_active at all. If you have changed your code to now use user_active, you must enter a new questions, as it is a brand new edit. I cannot provide ongoing support for your edits to this site, especially when the question was given the lowest possible value.

I do believe that line had two open parenthesis and only one closing. So that may be it. But if you need additional assistance, please enter a new questions, as the project that you gave me does not use that function at all.

Yes, I can change this function to use PDO. Again, this is in addition and unrelated to the question you originally asked on this thread. I would kindly ask that you enter it as a new questions, remembering to start it with **For TheDoctor**.

Thank you
Customer: replied 4 years ago.

**For TheDoctor**

no this is not new it is what it was from the beginning.

Look at the functions file. This is where the parse error is coming from I included the file from the beginning and I am still getting the original parse error. I am not revising anything or asking for anything extra this is what I asked for from the beginning

The original parse error was from line 196 of register.php, not from functions.php

And I just told you what the error with functions.php is. You are opening two parenthesis, but only closing it once. That is a parse error. It is easily fixed. Close the additional parenthesis.

As a Zend Certified Engineer, I can assure you that this parse error is in no way related to the register.php parse error that you originally asked about.

If you would like assistance changing it to PDO, please enter a new question.
Customer: replied 4 years ago.

**For TheDoctor**

I did include the functions file in to begin with and I asked you chnage everything to PDO. I am willing to pay extra if I think it fair but I don't think this is fair.

You did not asked me to change everything to PDO in your original question. You asked me to handle the parse errors. I did fix the parse errors for you. And I just told you how to fix this parse error in functions. If you cannot fix that error, please send me the file again and I will gladly fix it for you.

However, you did not ask me to change everything to PDO until well after your original question about parse errors. That was additional work that you added on after your original question. You are not technically allowed to add on additional requirements/requests to your question after your original question was asked. You added on the PDO request in addition to our original question. Yes, I had already done so in two of the files because it was a nice gesture. But it was not part of your original question. It is unfair to ask a question about parse error and then add on significantly more work in a much later post when that work was never mentioned in your original question.

However, you have been an excellent customer. I will attempt to change this for you, but right now I have no idea what you are attempting with this function.

function user_active($username) {
$username = sanitize($username);
return (mysql_result(mysql_query));

First, I see no function called sanitize in any of the code that you sent me. Second, I have no idea what you are attempting with that return. Perhaps a query is run in the sanitize function? I cannot find the sanitize function.

Additionally, this function is never called by any script that you sent me. If it were called, it would error out.

These are all additional issues completely unrelated to your original question:

1.) I have no sanitize function
2.) This function is never called from any of the scripts you sent me
3.) The return doesn't appear to make sense.
4.) This function would never operate if actually called from somewhere. It wouldn't be a parse error, but an undefined function error.

So there are many issues here, most of them in no way related to this question. I would need a description of what you are attempting to do here.
Customer: replied 4 years ago.

**For TheDoctorI**

I want to pass a 1 to the user table in column active so that a user cannot log in if they did not activate the account by email. I am willing to pay more if necessary.

Alright, what you are describing appears to be the activation page, which is currently working correctly. However, testing it takes a little additional work.

First, make sure that you correct that simple parse error in functions.php.

If you copy the code that I pasted in my last message and replace your function with that, it will fix the error. You had:

return (mysql_result(mysql_query);

And it should be:

return (mysql_result(mysql_query));

Just a closing parenthesis issue.

Now, when you register successfully, an email is sent out. That is working and I did test it. However, as you may or may not be aware, testing the mail function in PHP will usually not work if you are running code locally. That is because the mail function relies on the locally installed SMTP server. You probably are not running and SMTP server because there is no good reason why an individual would be running an email server. Usually, the mail command will not function until after the code is uploaded and running on an actual web server.

However, there is actually a way to test emails locally. Go here and download the test mail server tool. The entire purpose of this tool is to enable you to test emails.

Install it and run it. Once it is running, do not change any settings, just leave it running.

Then test your registration. When the registration page triggers the email, this test tool will intercept the call to mail and open the email in your default desktop email program (e.g., Outlook, Windows Live Mail).

You will see in the email that you are provide the full link to your school site. If you are running locally, obviously that link will not work. You would want to copy the part that start with activate.php? and go to your local version, making sure that you've copied the entire code. If you are running this from your school site, then you can simply click on the link.

Once the activation page loads and you have passed in the code from email, either by loading the file locally or by actually running all of this on your site, the activation page does currently change the active from 0 to 1 for that user. Until you have followed the link from the email, the user active is set to 0. And yes, the active.php page uses all PDO.

So, you see, the functionality you are describing is already implemented and functional.

Let me know if you have any other questions.

Thank you

Actually, the user_active function seems like it should return whether nor not a user is active. The activate.php page already handles activating a user, and does so correctly.

It would seem that the user_active function takes as an argument the user_id and returns either 0 or 1, so that you can use that function to check the active status of a user, not to change it. That way, you can use the function to prevent login. You made it sound like the function should change the active status of the user, which is what activate.php already does.

Is this correct? Should the user_active function take the user_id as an argument and return the user's active status? Then you can use it like:

if(user_active($user_id) == 1) {...

Is that correct?
Customer: replied 4 years ago.

**For TheDoctor**

this is correct

Customer: replied 4 years ago.

Where would put that and do I need the user_active() function?

Here is the updated functions.php:

The user_active function now uses PDO. It takes as arguments:

1.) The $dbh object
2.) The user name

So, it would be called like:

$active = user_active($dbh, $_POST['username']);

This would be part of your login post process. I don't even have your login page. If you need assistance implementing the login, I would kindly request that you enter a new question, as that is far beyond the scope of this question.

With PDO, you are using prepared statements. You do not need to do any extra sanitizing when using prepared statements. That is the entire purpose of using prepared statements.

Let me know if you have any other questions. Thank you.
Hello again,

I apologize for the earlier misunderstanding. I assume that this assignment is due today?

Are you supposed to be creating these pages in an MVC architecture? I ask because I noticed that while you have folders for model and control, your code does not conform to an MVC architecture at all.

Additionally, your data validation could be accomplished easier without using 8-level deep nested if statements. Your instructor may bring that up.

If you have additional time for this project, or if you have follow-up assignments based on this one, I would be happy to assist you get everything sorted.

Thank you again.