1

I'm having problems with getting started with pset7. firstly, after following the instructions carefully and downloading the files for pset7. I tried accessing the CS50 Finance page within my IDE but I could not access the webpage. Instead I got the following message.

enter image description here

I've checked that all of the permissions are correct with the directories and files for pset7 but I am still getting this permission denial message.

Secondly, I am able to open phpMyAdmin within the IDE and I have copied the SQL statements into the text box under the SQL tab but when I executed 'Go' I received the following error message indicating '#1046 - No database selected'

enter image description here

I know there must be a simple way to solve these problems but the instructions for the pset don't exactly help you much when one encounters problems like these. Any help out there would be much appreciated.

2

Do not use chmod 777 *. That will probably help you to get your site to load, but it is bad for security, and a terrible habit to get into. It's like taking the front door of your house off of its hinges rather than using a key.

I have written about these permission problems in many places already, but the short version which should get you running is to do the following:

find ~/workspace/pset7/ -type d |xargs chmod 755
find ~/workspace/pset7/ -name *.php |xargs chmod 640
find ~/workspace/pset7/ -name config.json |xargs chmod 640

That should fix everything. If it does not, you might also need to:

sudo find /var/lib/php5 -name sess_* |sudo xargs chown www-data:www-data

The real reason for these errors is that the permissions have changed since version 59 of ide50, and the problem specifications have not been updated to reflect the new permissions. See this post on the CS50 Reddit for more info.

EDIT: The issue with phpMyAdmin is a separate one, and I can't tell whether or not it's related until you fix your permissions.

Meanwhile, you can try the following commands in the Terminal to verify that the database exists:

mysql50 shell
show databases;
use pset7;
quit

EDIT2:

@ABor (below, in comments) -- find can be finicky. I've seen that message often. Unfortunately, I'm on a quick break at work, and can't reply in comments because mobile. It may help you to test using find on its own, without | xargs. A more detailed explanation can be found here.

| improve this answer | |
  • Thanks for the advice. I've managed to fix the permission problems now from the advice via the this link from DinoCoderSaurus post below. I used the commands you posted above in the Terminal and I got the following back: – Mark Edwards Aug 17 '16 at 20:21
  • ERROR 1049 (42000): Unknown database 'pset7' – Mark Edwards Aug 17 '16 at 20:30
  • Sounds like you have not created the database. Was the pset7 database listed when you typed show databases; in the MySQL shell? Go back to the problem spec and read more closely. You'll need to run the code in the pset7.sql file to create the database, and the users table, before you can INSERT INTO the users table. – hotwebmatter Aug 17 '16 at 23:24
  • 1
    Hello @Matt. I was executing the 3 find commands that you have mentioned above. While the 1st and 3rd command worked well, the 2nd command is returning an error, which is ~/workspace/pset7/public/ $ find ~/workspace/pset7/ -name *.php |xargs chmod 640 find: paths must precede expression: login.php Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression] chmod: missing operand after ‘640’ Try 'chmod --help' for more information.. Can you please guide me on this so that I can get started with the pset? Thanks. – ABor Sep 6 '16 at 13:46
  • 1
    Hello @Matt. The command with the . (dot) operator worked. Now I'm able to access the CS50 Finance page. Thank you for your help. – ABor Sep 7 '16 at 4:17
1

First, you are not nuts. I completed pset7 in may 2016 and everything worked perfectly with the detailed permissions as written in the specification.

After a few months of heavy workload, I came back to edx to do pset8 in August 2016 and my partially working code no longer ran -- permission errors. To sanity check myself, I reloaded apache50 in the pset7/public directory and got the same errors you did.

I launched an email to the course leads, but no response yet. I also noticed that update50 has been changing a bit lately. I suspect the team is getting ready for the fall semester (a good thing) and that is what has their mind share. Either that, or one last vacation...

| improve this answer | |
0

I have tried what you've suggested and also some suggestion on the reddit forum but I am just getting the following errors. It's very frustrating when you cannot even get started. I've spent hours trying to resolve this problem.

enter image description here

| improve this answer | |
0

I know it seems like the long and winding road, but this worked for me.

| improve this answer | |
  • 1
    Your suggestions via your 'this' link seems to have solved the permissions problem for me and I've managed to get access to the login page of CS50 Finance but I am still stuck with the phpMyAdmin problem above. Any suggestions? – Mark Edwards Aug 17 '16 at 20:01
  • 2
    make sure you paste the whole pset7.sql file into myPhpAdmin. It is 36 lines. After a few comments you should see the lines CREATE DATABASE IF NOT EXISTS pset7; USE pset7; starting at line 5. Based on the line numbers in the screenshot, you're missing the all important 26 lines before it inserts users data. – DinoCoderSaurus Aug 17 '16 at 22:28
  • I did as you suggested and what do you know. It worked! Thanks once again for your help. – Mark Edwards Aug 18 '16 at 17:35
  • @DinoCoderSaurus Wow, I'm an idiot. For some weird reason I thought the instructions meant to only copy the INSERT lines lol – tamj0rd2 Nov 9 '16 at 12:59
-1

I came back to CS50 after a few weeks - everything worked fine when I left. Mistake was to update50 to version 60. All permissions are off. You literally have to go to EACH file and chmod 777 - lower could work but then you have to spend time reading the file to see if they need r? w? (is filling in a box writing?????) or x - hey footer and header needed x. I gave everything everything.

| improve this answer | |
  • footer.php and header.php do not need to have the execute bit set for user, group, or world. In fact, PHP files generally do not need the execute bit set at all, because they are not "executed" like C files. Rather, the web server executes the PHP interpreter, which only needs to read the PHP file and interpret it. This is why the documentation says to use chmod 600 -- and due to the permission changes since version 59 of ide50, now chmod 640 is required. – hotwebmatter Aug 19 '16 at 19:33
  • One exception: if you are going to execute a PHP script from the command line, you can set the permissions to chmod 700 so that no other user has permission to execute the script -- and in this case, you must also include the "shebang" line #!/usr/bin/env php as the first line of your file. – hotwebmatter Aug 19 '16 at 19:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .