Hot answers tagged

28

The "Connection for controluser as defined in your configuration failed" problem can be eliminated by refreshing the configuration of the the phpmyadmin package. Open a terminal window by clicking the terminal icon to the right of the colorful Chrome icon near the lower left corner of the appliance screen. In that terminal, run sudo dpkg-reconfigure ...


23

CS50 course materials will tell you that the permissions need to be set as follows: chmod 711 for directories chmod 644 for images, HTML, CSS, JavaScript chmod 600 for PHP files. In general, this is the correct advice. However, if you have run update50 recently, you should know that there is a bug requiring chmod 640 instead for PHP files. I've posted this ...


15

I found that deleted post over on reddit with an answer from delipity. But the user continued to have problems. I unzipped a fresh pset7, and did these chmods and finally got RockRolld! (oops. Spoiler :). I then removed pset7 and reinstalled, then followed this list and got the same (positive) result. I am running IDE 62. Full disclosure, I did not reinstall ...


13

This is the same solution as posted in Reddit, simply with clean code ready for copy/paste to terminal. Please note that you have to start in "workspace" directory. chmod 711 pset7 cd pset7 chmod 755 public cd public chmod 711 css fonts img js chmod 644 css/* fonts/* img/* js/* cd .. chmod 711 includes vendor views chmod 644 includes/* ...


12

There is nothing in the spec saying to output the purchase price to the user. That is because such a page is not required. check50 is parsing your index.html page after it makes one purchase, so it should find the current value of those shares 112.00 and the updated value of cash (10000-112) 9,888.00 If I had to guess, I'd say that you aren't formatting ...


10

Apologies for the inconvenience! Should be fixed ASAP! But until it's fixed, yet another solution to this is to execute: $ echo "#includedir /etc/sudoers.d" | sudo tee -a /etc/sudoers in a terminal tab, and restarting all terminal sessions, by right-clicking inside a terminal and choosing Restart All Terminal Sessions. Then, try executing the apache50 ...


8

This can happen if the info50 script is missing from /usr/bin.* You can execute password50 from a command line to get your mysql password (and similarly, username50). *The footnote is much longer than the answer. I could reproduce this by creating a new workspace using the CS50 template. After running update50, the log ($HOME/lib/ide50.log) reports ...


8

Due to a recent update the permissions required has changed, but the specifications has not been updated. All PHP files and config.json must now be set to chmod 644, whilst all directories must be set to chmod 711. If that did not solve your problem, here are some threads that might. https://www.reddit.com/r/cs50/comments/5055ti/...


8

I had the same problem. In the end I've solved it by getting rid of DISTINCT and using both ORDER BY and GROUP BY. Hope that helps!


7

It doesn't select any rows because there is no people record with both those names. The immediate suggestion would be to use OR instead of AND. Another option would be to use an alias of the people table to join it as "another" table, each (people and "another") joined on one of the names. It would be easy to create a list of Johnny Depp ...


6

First, after WHERE you should specify column name(s). So this call to query() $rows = query("SELECT * FROM `stocks` WHERE $id"); should be like that $rows = query("SELECT * FROM stocks WHERE columnName = ?", $id); Second, the function query() returns a number of rows, at the first place, where each row is composed of columns. Meanwhile, if you tried to ...


6

I'm sorry if it's not appropriate to answer your own question but I'd like to post the solution to this problem just in case someone has the same issue. The commands sudo /etc/init.d/mysql start sudo /etc/init.d/mysql stop sudo /etc/init.d/mysql restart solve the issue.


6

UPDATE 24-Dec-2016: As of IDE version 94, this has been fixed. Suspect some cloud9 change. For the "more comfortable", a patch is needed in apache50 script. You need elevated permissions. (I used sudo vi /usr/bin/apache50) change line 21 in /usr/bin/apache50 from apache="sudo -S -u www-data service apache2" to apache="sudo sudo -S -u www-data service ...


6

Use hash instead of encrypt in your register function. I tried it, it worked for me. I was able to sign on as an existing user, or register (and sign on as) a new user. I am not advocating blindly using functions without reading and understanding the doc. Except maybe on a beautiful, sunny, lazy, Sunday afternoon :)


6

When an obviously correct line gives a syntax error, look to the preceding line. Are there enough ')' on the db.execute?


6

Your DISTINCT would make the result records appear only once. But that means the name, and multiple stars might share a name. In other SQL dialects you could use DISTINCT ON (col1, col2) with an "ON" and a list of columns to use for the DISTINCT, but SQLite does not seem to support such thing. I actually solved this by applying the DISTINCT to a sub-query ...


5

Thank Brenda Anderson from Facebook group CS50 for providing a new code for helpers.py


5

It's because in your first query you said where id = (.... this query here is expecting only 1 value so in the query inside the parentheses the first value it gets is the only value that is checked. To make your query correct all you have to do is change the = with IN, the IN command here checks a list of values. e.g. SELECT * FROM smth WHERE name IN ('...


4

Not really. The function query uses another function from the standard library namely prepare that prevents SQL injection attacks by eliminating the need to manually quote the parameters as the documentation suggests. The idea is fairly simple, but first, let's see what a prepared statement means. As this article suggests, Prepared statements, also ...


4

The request method is GET by default. When the user visits http://pset7/sell.php, she is requesting the page (i.e., sell.php in this case) using GET. Therefore, the condition $_SERVER["REQUEST_METHOD] == "POST" is initially false and the else branch is executed as a result. To fix this, you need to render the template if the requesting method is not POST (...


4

To solve this issue, you need 2 variables. Let's call them $userinfo and $cash. First use query() to get cash value from the row with the id that is contained in $_SESSION. Then use this line of code to put the cash value into $cash. $cash = $userinfo[0]["cash"]; Then you can put cash in print, and it will print out the user's cash.


4

Permissions have changed due to a recent update, but the problem specification has not been edited to reflect this. PHP files and config.json now need to be set chmod 640, even though the problem specification says chmod 600. Also, all directories need a minimum of chmod 711, which your public directory has currently, but others like vendor and views do not....


4

If you want to run your own git server on cloud9, I have to warn you that it's a very long process and very easy to screw up. If you still want want to set up your own server, take a look at this from the official site of Git: Git on the Server. Instead, I would suggest you use GitHub (most popular but your code is public for the free account) or Bitbucket (...


4

403 Forbidden / permissions / chmod: the Definitive Guide TL;DR: PHP files and config.json need to be set to chmod 640 despite what it says in the Problem Specification. Hope this helps!


4

The root cause is a Cloud9 change, github bug to track here: https://github.com/cs50/ide50/issues/27 DinoCoderSaurus's workaround should work until they update the cs50 ide. Also: you should learn to use vi! Simple steps for this case: $ sudo vi /usr/bin/apache50 press 'i' to enter Insert mode make your changes (using the arrow keys to navigate) press ...


4

Since "stocks" are in one list and "currentprices" are in another list you will get this result when you use two lists and two loops. One solution would be to use one loop and use currentprices[i] where i is indexed to the row in the "stocks" list. Another option would be to add a "price" key to each "stocks" row in the index() function instead of building ...


4

Inside the function for the respective routes you can just call the function "flash(message)" before the "return redirect()" function, where "message" is the message you want to display. for example: flash ("Bought") return redirect(url_for("index"))


4

All very good questions. You're thinking about what redundancies can be eliminated. But then, you need to think further. What's more important, conserving storage or making queries more efficient? First, look at the case of the zip code table. Zip codes are essentially unique and constant. Info related to cities and zip codes rarely change. Linking back to ...


4

SOLVED. I added the following: try: shares = int(request.form.get("shares")) except ValueError: return apology("shares must be a posative integer", 400) I was under the impression that, since I was receiving the popup error before posting /buy, there was something else causing the problem.


4

The last line in the log about errorhandler is a red herring. More on that later; will edit after proper research. The important line in the log is where it says something about bind parameters (if log was posted as text not image I could cite it here). This result=db.execute("SELECT * FROM users WHERE username = :username") is not proper syntax. When ...


Only top voted, non community-wiki answers of a minimum length are eligible