1

Just finished the 22 min video of David Malan in the specs of pset8 and I feel like I just understood 10% or even less of what he said, Really scared now dont wanna quit on the last pset. What study material should I look into if I have problems in completing this pset or what functions do I need to really understand in the the distribution code , in order to complete this pset? Any help or hint or tip would really be appreciated

1 Answer 1

2

Congratulations on finishing Problem Set 7! :)

Problem Set 8 is a lot to learn all at once, but don't quit.

As with other Problem Sets, just break this one down into small steps and tackle each one at a time.

First, work on writing the import PHP script. It's easier than it looks.

It's a lot like those C programs you wrote a long time ago, the ones that indexed into the command-line argument vector argv. Except in PHP it will be called $argv!

It will also use the CS50 Library to connect to a database, which should be familiar now that you have completed Problem Set 7.

In pseudo-code:

#!/usr/bin/env php
<?php
    // TODO: import places from US.txt into mySQL db

    // display errors, warnings, and notices

    // CS50 Library

    // Validate arguments
    // open a filehandle to read data
    // US.txt is basically a CSV, but delimited by "\t" instead of ","
        // put it in the database
    // remember to close the filehandle
?>

Once you have the locations in your database, move on to the next task.

Follow the Problem Specification closely. Do things one step at a time!

Do not attempt to understand everything all at once, or your head may explode.

Good luck!

5
  • I have just finished pset7 and started pset8 too. Pset8 does look daunting but I want to finish the course. I have written the php script for import but when I have tried to run import from the command line to import the US.txt csv file into the phpMyAdmin places table I keep getting the following error: Commented Oct 22, 2016 at 10:23
  • ./import: Permission denied Is there a problem with the permissions with the csv file or perhaps should the import file have a .php extension? I would appreciate some help with this because at the moment I am stuck and I'm unable to move forward with this pset. Commented Oct 22, 2016 at 10:33
  • @MarkEdwards: The problem is with the permissions on ./import, which should be set chmod 700. (User needs rwx, group and world don't need any permissions since this is a PHP command-line script.) You're seeing that error because the executable bit is not set +x for the user that's trying to execute the import. Also, the .php extension is optional here; the only reason to use it would be to tell the c9 editor in the Cloud9 IDE what sort of syntax highlighting and auto-completion to use. Commented Oct 22, 2016 at 12:59
  • I set the permissions on ./import to chmod 700 but now I'm getting the following error, from the command line: Fatal error: CS50 library requires bcmath or bmp extension module in /home/ubuntu/workspace/pset8/vendor/library50-php-5/CS50/CS50.php on line 48 Am I missing out something here in my import file php script file? Commented Oct 22, 2016 at 15:02
  • @MarkEdwards: I'm glad that you fixed your permissions. Your CS50 library error is a separate and unrelated problem. We should try to keep the solution with the relevant question, and not discuss it in the comments to another question. Commented Oct 22, 2016 at 22:15

You must log in to answer this question.

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