0

I had two questions about pset7 and thought I'd post them together.

The first regards styling. Just for fun, I wanted to try changing the CS50 Finance logo that appears on the top of each webpage to a different image. However, despite saving an image from the web in the same folder (public/img), my image doesn't display. Does it need to be a gif? And if so, why does it need to be a gif? My girlfriend, who is a web designer was a little confused on this point.

My second question regards quote.php. No matter what stock symbol I type in (GOOG, FB, etc.) I receive an apology message that says that the stock symbol is invalid. I also receive this message at the top of the page in an error box:

Notice: Undefined index: symbol in /home/jharvard/vhosts/pset7/public/quote.php on line 7

My code checks to see if lookup($_POST["symbol"]) is false, and if it is, it should apologize. It seems that this lookup is always returning false, and that something is wrong with this line of code:

$stock=lookup($_POST["symbol"]);

Or maybe this one?

if($stock===false)...

Any help on either of these two issues, or both, would be great! The first would be helpful for lots of people. The second might just be a personal issue...but then again, it's possible others will have this problem as well.

1

@user1298: Glad you fixed the typo. Now to determine why your JPEG image is not displaying, open a Terminal and execute the following command:

ls -l ~/workspace/pset7/public/img/

You should see something like this:

~/workspace/ $ ls -l ~/workspace/pset7/public/img/
total 256
-rw-r--r-- 1 ubuntu ubuntu 243973 Oct 26  2015 logo.png
-rw-r--r-- 1 ubuntu ubuntu  12461 Aug  4 21:04 logo.jpg

If the permissions on logo.jpg are not -rw-r--r--, you can fix that with chmod 644. In fact, I recommend that you do so for all images:

chmod 644 ~/workspace/pset7/public/img/*

Be sure to let me know if that was the problem!

| improve this answer | |
0
  1. The image shouldn't have to be a gif, but without seeing the code in question any guess as to why it's not working would be speculation.
  2. What's happening is that you're attempting to access an element of $_POST without using isset() or empty() to make sure there is a value there, and at least in the instance when you ran into the error there was no value assigned to $_POST['symbol']
| improve this answer | |
  • 1
    I fixed the second problem at least. There was a very pernicious typo floating around... – user1298 Jun 17 '14 at 0:43

You must log in to answer this question.

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