As of May 31, 2023, we have updated our Code of Conduct.

Hot answers tagged

3 votes

How to link submit button with the <select> list in HTML?

You can achieve that using JavaScript: <div> <h1>SELECT A TOPIC</h1> <select id="select"> <option value="physics">physics</option> <option value="...
Michał Perłakowski's user avatar
3 votes

phpMyAdmin: "mysql extension missing" error

We all know that phpMyAdmin can be flaky sometimes. Unfortunately, I can't tell you how to fix it -- but I can tell you how to use mysql50 shell from the command line. Try stuff like this: mysql50 ...
hotwebmatter's user avatar
  • 3,046
2 votes
Accepted

How to determine how much cash a user has in C$50 Finance's portfolio.php

Yes your logic is correct, and this is exactly the way the world works. Say I have $20. I buy a diamond for $10. So now I have $10 left. In a week from now, the same diamond, costs $5. But I still ...
ChrisG's user avatar
  • 7,366
2 votes

pset8 (mashup) - Inserting $places variable into configure function in scripts.js

I figured it out. <%= ... %> is indeed the way you pass in arguments to _.template. When I watched the video in the problem set again the prof mentioned how this code operates similarly to the "%i" ...
plumsmugler's user avatar
2 votes
Accepted

register php pset7 query to INSERT do not work

Such a subtle thing. Your are inserting 3 columns (username, hash, cash). The computer thinks you are sending 4 values because of the comma in your cash amount. VALUES(?, ?, 10000,00)
DinoCoderSaurus's user avatar
2 votes
Accepted

When I run my apache50 server at ~/workspace/pset7/public why does login.php files open?

From the pset instructions: Know that index.php is the file that’s loaded by default when you visit a URL like https://ide50-username.cs50.io/. ...which calls (redirects to) login.php (via ...
DinoCoderSaurus's user avatar
2 votes

include 'file.php' does not seem to work

You've probably gotten used to using #include statements in C. The equivalent function in PHP is require(). If you have access to pset7 or pset8, just look at the distribution code provided. You'll ...
hotwebmatter's user avatar
  • 3,046
2 votes
Accepted

syntax error, unexpected 'for' T_FOR

Not all of them! $alphacount = 0 :)
DinoCoderSaurus's user avatar
2 votes

cs50::init(_DIR_."/../config.json") pset7

To answer the specific question from your comment "why is :: used?" From the config section of the spec (That :: syntax just means that init is "inside of" an "object" called CS50. An object in ...
DinoCoderSaurus's user avatar
1 vote
Accepted

How difficult are pset7 and pset8?

PHP is much easier than C in many ways. You definitely won't need to worry about pointers and malloc() and free() any more! You will be doing some file I/O, but nothing involving low-level file stream ...
hotwebmatter's user avatar
  • 3,046
1 vote

pset7 reset password php mail function doesn't send email

OK, I want you to try exactly what I did: Execute the following to make sure you have git installed, and wait for the command to finish sudo apt-get install git Execute the following to get the ...
ChrisG's user avatar
  • 7,366
1 vote
Accepted

PSET8: fopen() not working for import

You added an extra unwanted ; on this line: if ($handle == FALSE); Remove the semicolon and it will work as wanted.
ChrisG's user avatar
  • 7,366
1 vote

Drop-down Menu for Sell_View.PHP gives empty options

How are you passing the php variable from your controller to your viewing page (sell page)? You are storing the array returned by your mysql query in $symbol, but it looks like you are passing $stocks ...
ronga's user avatar
  • 1,415
1 vote
Accepted

How to make search.php return results that are more relevant

It's as simple as turning this and obviously I would prefer "Cincinnati, OH" to be the first result. into computer code :) Kinda moves into the realm of computer learning/intelligence. First ...
DinoCoderSaurus's user avatar
1 vote

How should I connect to the multiple databases?

Admittedly I don't fully grasp what you mean "merge several psets". However,in the narrow and specific context of CS50 pset7 & pset8, you do not need two databases. Consider adding the places ...
DinoCoderSaurus's user avatar
1 vote
Accepted

week7 lecture2 source code speller.php not found

From your first link choose Index in the Source Code pane (far right). Choose misspellings/. Click on download to the right of speller. It will open with a text editor (like notepad++). It's also in ...
DinoCoderSaurus's user avatar
1 vote
Accepted

pset6: PHP Templating and Indexes

about your /test problem, you forgot to check if the path already has a '/' at the end, and add it if it's not the case.
user3781458's user avatar
1 vote
Accepted

Debugging in Problem Set 7: CS50 Finance

I forgot to answer my own question. Using dump() is better than using print statements
David's user avatar
  • 121
1 vote
Accepted

Looking at the course, could I use PDO instead of mysql?

as you reach pset7, the first pset that you are going to interact with a database in it, you won't have to write your own code to connect with your database. instead, there is a query function ...
kzidane's user avatar
  • 17.6k
1 vote
Accepted

PSET8 import undefined offsets and fatal error

The problem is your input data. Your query is expecting 12 values on every line. The first line in your example has 9. You "lost" the blank columns from the text file, presumably when you converted ...
DinoCoderSaurus's user avatar
1 vote
Accepted

PSET8 import fatal error

The problem is your insert query. You are inserting 12 columns, you have 12 ? placeholders, but you are sending 13 arguments. Also, beware: implode returns a string. So you $str_values[0] et. al. ...
DinoCoderSaurus's user avatar
1 vote

Printing from SQL in PHP

recall that, assuming the query is syntactically correct, query returns an array of the resulting rows (if any) or an empty array otherwise. try print_r'ing $comment to learn about the structure of ...
kzidane's user avatar
  • 17.6k
1 vote
Accepted

pset7 php generated html appearing above CS50 finance header

Ignore this, It was actually fixed very easily by switching the order of the render function and the array loop. Doh!
Kris Valentine's user avatar
1 vote
Accepted

Escaping Characters in PHP

the first argument that preg_match takes according to the documentation is a pattern. that is, a regular expression to test $destination against in this case. the forward slashes (i.e., /) at the ...
kzidane's user avatar
  • 17.6k
1 vote
Accepted

Finance: Buy/Sell does not insert into MySQL history table

Try checking your index+ link on the Structure view. I deleted all my unique and primary keys, as well as any links to other tables. This solved the problem..thanks to Kareem .. and, I apologise for ...
Ronnie's user avatar
  • 28
1 vote

Array in php vs R (pset7 sell.php)

Just like _POST your positions is an associative array. Just as you get $_POST["symbol"] you get $positions["price"]. If I understood correctly you want to do something like the following <?php ...
ChrisG's user avatar
  • 7,366
1 vote
Accepted

CSS Table Gradient Not Working

I made something simple but I think you can tinker further on your own: grad.html <!DOCTYPE html> <html> <head> <link rel="stylesheet" type="text/css" href="style....
ChrisG's user avatar
  • 7,366
1 vote
Accepted

Path to PHP Interpreter

If I understand correctly you mean the path to php interpreter so that to use a #! to make it executable. It's #!/usr/bin/env php.
ChrisG's user avatar
  • 7,366
1 vote

Path to PHP Interpreter

I think the simplest answer is php <filename>. So if you have a php file called hello.php that looks like this: <?php printf("Hello, world!\n"); ?> you would run php hello.php and you'd ...
curiouskiwi's user avatar
  • 18.5k
1 vote
Accepted

How to Redirect Only When a User Clicks Ok on a Popup?

If you want to use the redirect() function provided in pset7 I'm not sure how, but in general you can do it like so: echo "<script type='text/javascript'> if (confirm('Want to redirect?'...
ChrisG's user avatar
  • 7,366

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