1

I'm currently on my final project, and I want to link my php code to excel files (using fgetcsv() and fputcsv()). However, I don't have excel on the cs50 appliance, so my question is:

How can I use gedit and command prompt for Windows just like how I've been using them in the appliance? What are the steps I need to take in order for the windows command prompt to run a .php file? Is it possible for my Windows machine to behave just like the CS50 appliance? (it hasn't worked for me as, for example, command prompt doesn't recognise the 'php' command)

I can imagine other people having the same problem.

Please bear in mind I'm very new to all this computer software stuff!

Thank you very much, any help would be appreciated!

1

You don't need Excel to open a csv file, you can open it even with a text editor like gedit in the appliance. I think your best move would be to install Libre Office on the appliance. They have a great spreadsheet tool just like Microsoft Excel. https://www.libreoffice.org/download/libreoffice-fresh/

Edit

Then I would suggest you instal WAMP on your Windows OS (http://www.wampserver.com/en/). It installs an Apache2 server, run PHP files, access a MySQL database and PhpMyAdmin. In short, what you can do with the appliance. It may take you a while to figure out how to use everything, but not more than a few hours. If you have questions, google them or ask here.

Sidenote

Since you said something about a school project, I would suggest you take a look at the CS50 Academic Honesty, specifically the following bullet points:

  • Submitting the same or similar work to this course that you have submitted or will submit to another.
  • Submitting work to this course that you intend to use outside of the course (e.g., for a job) without prior approval from the course’s heads.

Edit 2

First locate the path to the php interpreter the WAMP installed, it should be on a path like:

C:\wamp\bin\php\php5.5.12

(You may have a different version, if so go to that folder)

Then copy this path, and paste it on the Windows Environment Variables.

To do so,

  1. right click My PC -> Properties.
  2. On the left menu select Advanced System Settings.
  3. At the bottom select Environment Variables.
  4. On the System Variables Textarea double click "Path".
  5. Paste the path you copied earlier on the beginning of this line, followed by a semicolon ';' (no space after the semicolon)

Now restart your PC. When you open up command line the next time, type

php -v

You should see the version of php. From there on you can use it as usual.


Now if you want to execute an executable you have compiled in windows from source code (like C code), you don't do it by

./hello

but just

hello

Take a note here that the executable has to have been compiled on a windows machine, and not on *nix like the appliance. They have different ways the compile the source code.


As for ls the command to list the contents of a folder in windows id dir.

7
  • Thank you for your comment, but my cs50 final project ties in with my school project, which definitely requires Excel... Is there no way I can, say, write a program in Windows that pulls data from the web just like the C$50 finance pset? Again, sorry if I sound ignorant/stupid, all this is confusing to me!
    – Ivan Chan
    Aug 26 '15 at 7:54
  • Check the edits.
    – ChrisG
    Aug 26 '15 at 8:04
  • 1
    That is fantastic, thank you very much! And regarding the school project, there is nothing to worry about; I am implementing something similar to C$50 finance pset for the cs50 final project, but my school project will only use the "stock analysis" that will hopefully result from the cs50 final project rather than the actual final project itself. I think this question is now answered as that was exactly what I wanted. Thank you again ChrisG
    – Ivan Chan
    Aug 26 '15 at 8:17
  • Actually, I hope this is allowed, but I have one quick question: do you know how to actually run the php program? in cs50 appliance it would be "php program.php" in the terminal, but window's command prompt doesn't recognise this? it also doesn't recognise "./" or other commands like "ls"? Thank you
    – Ivan Chan
    Aug 26 '15 at 9:44
  • See the second edit.
    – ChrisG
    Aug 26 '15 at 12:15
0

php is a server side script so windows will not be able to run it. But if all you need is for php to be able to access an .xls file, 1 way of doing it would be to upload the file to the vhosts directory and access it from there. Directions for transferring files from your PC to the appliance are on the course home page, appliance reference link is on the right.

2
  • thank you for your advice, but I'm a little confused; isn't the cs50 appliance just a virtual machine, i.e. just another OS, so wouldn't it mean the windows OS must also capable of whatever the appliance is? Sorry if I sound ignorant, but all this is very new to me!
    – Ivan Chan
    Aug 26 '15 at 7:50
  • It's not just another os, linux is the os it runs on. What it does, though, is it enables you to run server-side script like php, which you wouldn't be able to do from your browser. Requests to web servers are dealt through php script. If you want to do it via your browser, you can do so through js.
    – ronga
    Aug 27 '15 at 1:29

You must log in to answer this question.

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