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
TheDoctor, Professional w/Adv. Degree
Category: Homework
Satisfied Customers: 1452
Experience:  M.S. in Internet Information Systems
59032869
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

Resolved Question:

**For TheDoctor**
I have a question for you if you can this answer me. I will send the question.
Submitted: 1 year ago.
Category: Homework
Expert:  TheDoctor replied 1 year ago.
Hello again! Thank you for requesting me.

Please send me the details. If you have any documents to share, you can upload them to http://ge.tt

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 1 year ago.
Customer: replied 1 year 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


Thanks

Expert:  TheDoctor replied 1 year ago.
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 1 year ago.

http://ge.tt/3xOh9vh?c


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

Expert:  TheDoctor replied 1 year ago.
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 1 year ago.

http://ge.tt/2Zmp0vh?c


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

Expert:  TheDoctor replied 1 year ago.
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 1 year ago.

http://ge.tt/2Zmp0vh?c

Expert:  TheDoctor replied 1 year ago.
Hello again,

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

Thanks Doc

Expert:  TheDoctor replied 1 year ago.
Hello again!

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

Attachment: 2013-05-29_051616_fixed.zip



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 1 year ago.

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

Expert:  TheDoctor replied 1 year ago.
THIS ANSWER IS LOCKED!
You can view this answer by clicking here to Register or Login and paying $3.
If you've already paid for this answer, simply Login.
TheDoctor, Professional w/Adv. Degree
Category: Homework
Satisfied Customers: 1452
Experience: M.S. in Internet Information Systems
TheDoctor and 9 other Homework Specialists are ready to help you
Customer: replied 1 year 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


 

Expert:  TheDoctor replied 1 year ago.

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 1 year 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))
138}


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

Expert:  TheDoctor replied 1 year ago.
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 1 year 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

Expert:  TheDoctor replied 1 year ago.
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 1 year 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.

Expert:  TheDoctor replied 1 year ago.
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 1 year 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.

Expert:  TheDoctor replied 1 year ago.

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

Expert:  TheDoctor replied 1 year ago.
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 1 year ago.

**For TheDoctor**


this is correct

Customer: replied 1 year ago.

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

Expert:  TheDoctor replied 1 year ago.
Here is the updated functions.php:

http://wikisend.com/download/828120/functions.zip

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.
Expert:  TheDoctor replied 1 year ago.
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.

JustAnswer in the News:

 
 
 
Ask-a-doc Web sites: If you've got a quick question, you can try to get an answer from sites that say they have various specialists on hand to give quick answers... Justanswer.com.
JustAnswer.com...has seen a spike since October in legal questions from readers about layoffs, unemployment and severance.
Web sites like justanswer.com/legal
...leave nothing to chance.
Traffic on JustAnswer rose 14 percent...and had nearly 400,000 page views in 30 days...inquiries related to stress, high blood pressure, drinking and heart pain jumped 33 percent.
Tory Johnson, GMA Workplace Contributor, discusses work-from-home jobs, such as JustAnswer in which verified Experts answer people’s questions.
I will tell you that...the things you have to go through to be an Expert are quite rigorous.
 
 
 

What Customers are Saying:

 
 
 
  • Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C. Freshfield, Liverpool, UK
< Last | Next >
  • Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C. Freshfield, Liverpool, UK
  • This expert is wonderful. They truly know what they are talking about, and they actually care about you. They really helped put my nerves at ease. Thank you so much!!!! Alex Los Angeles, CA
  • Thank you for all your help. It is nice to know that this service is here for people like myself, who need answers fast and are not sure who to consult. GP Hesperia, CA
  • I couldn't be more satisfied! This is the site I will always come to when I need a second opinion. Justin Kernersville, NC
  • Just let me say that this encounter has been entirely professional and most helpful. I liked that I could ask additional questions and get answered in a very short turn around. Esther Woodstock, NY
  • Thank you so much for taking your time and knowledge to support my concerns. Not only did you answer my questions, you even took it a step further with replying with more pertinent information I needed to know. Robin Elkton, Maryland
  • He answered my question promptly and gave me accurate, detailed information. If all of your experts are half as good, you have a great thing going here. Diane Dallas, TX
 
 
 

Meet The Experts:

 
 
 
  • Manal Elkhoshkhany

    Tutor

    Satisfied Customers:

    4520
    More than 5000 online tutoring sessions.
< Last | Next >
  • http://ww2.justanswer.com/uploads/BU/BusinessTutor/2012-2-2_115741_Kouki2.64x64.jpg Manal Elkhoshkhany's Avatar

    Manal Elkhoshkhany

    Tutor

    Satisfied Customers:

    4520
    More than 5000 online tutoring sessions.
  • http://ww2.justanswer.com/uploads/LI/lindaus/2012-6-10_04811_IMG20120609164157.64x64.jpg Linda_us's Avatar

    Linda_us

    Finance, Accounts & Homework Tutor

    Satisfied Customers:

    3121
    Post Graduate Diploma in Management (MBA)
  • http://ww2.justanswer.com/uploads/ComputersGuru/2010-02-13_051118_Photo41.JPG LogicPro's Avatar

    LogicPro

    Engineer

    Satisfied Customers:

    3035
    Expert in Java C++ C C# VB Javascript Design SQL HTML
  • http://ww2.justanswer.com/uploads/lanis/2009-4-1_233717_phput9xef_c1pm.jpg Lani S.'s Avatar

    Lani S.

    Tutor

    Satisfied Customers:

    2457
    Registered Nurse, Internet Researcher, Private Tutor
  • http://ww2.justanswer.com/uploads/chooser77/2009-08-18_162025_Chris.jpg Chris M.'s Avatar

    Chris M.

    M.S.W. Social Work

    Satisfied Customers:

    2341
    Master's Degree, strong math and writing skills, experience in one-on-one tutoring (college English)
  • http://ww2.justanswer.com/uploads/JawaadAhmed/2009-6-27_12137_SIs_SHadi.jpg F. Naz's Avatar

    F. Naz

    Chartered Accountant

    Satisfied Customers:

    1975
    Experience with chartered accountancy
  • http://ww2.justanswer.com/uploads/JK/jkcpa/2011-1-16_182614_jkcpa.64x64.jpg Bizhelp's Avatar

    Bizhelp

    CPA

    Satisfied Customers:

    1873
    Bachelors Degree and CPA with Accounting work experience