Hot answers tagged

2

Does it give errors in the console? It does. Have a look to see if you can figure it out. Hint in the spoiler.


1

added_user = db.execute("INSERT INTO users (username, hash) VALUES(:username, :password_hash)", username=username, password_hash=password_hash) is going to fail if the username is taken, as you've seen. To handle this, use a try except to catch and handle it, rather than just checking if your result is 0.


1

The problem is simple. Your placeholder for hash in the sql insert statement is hash but then you have used hash_p instead of hash when assigning the value. Hope this helps. If it does then please check the tickmark.


1

The problem is this code: else { node *p = malloc(sizeof(node)); p->next = index[i]->next; while (p->next != NULL) { p = p->next; } p = n; } It serves no useful purpose. All it does is create a new node p and point it at the new node n that you just created. Worse, there's ...


1

Your problem is that you have too many ; in your query. You only place a ; at the very end of your SQL query, not at the end of each SELECT statement. Unless you are performing multiple different, unrelated queries or are coding a procedure/function, you will only have a single ;. So, remove all of those and then see if that works. Also, while I do not do a ...


1

This is one of, if not the most common error made by new programmers. ;-) Look at the following: if ((final = 1)) Note the single = sign. This is an assignment, not a comparison. It is assigning 1 to final. An assignment in an if statement always evaluates as true, no matter what numbers are assigned. (An assignment statement returns a value that ...


1

The 'duplicate' check first registers a new user (which would return a 200) and then tries to register that same user (which would return a 400). The error you are seeing saying it was expecting a 200 and didn't get it. That tells me that it is the initial registration that is failing. If you delete all the rows from your user table and run check50 again, ...


1

If this is still relevant to you, here are some resources you might find useful: A novice’s guide to learning to code with CS50 I’m not going to lie and tell you that completing CS50 was easy. As someone with no prior coding experience and a background in the humanities, there were times when I found the course incredibly difficult. Ultimately patience and ...


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