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,050
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,050
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 can I update the version of php on my cs50 appliance?

You don't need to update it to complete your problem sets. update50 will take care of the necessary updates. If you are done with your problem set. you can download apache, mysql, php7, phpmyadmin to ...
A.Emad's user avatar
  • 176
1 vote

illegal string offset error in portfolio

Each time you do this $positions[] = ["price" =>number_format($positions["price"],2,'.',',')]; there is a row added to the $positions array that does not have "name", "shares" or "symbol". Ditto ...
DinoCoderSaurus's user avatar
1 vote
Accepted

Pset7 - Portfolio: $positions not filling

Oh. My. Goodness. My 2nd test condition wasn't a valid stock (just some random capital letters that I thought looked like an actual stock symbol) so if ($stock !== false) would kill the foreach() ...
Casey Belcher's user avatar
1 vote
Accepted

Do calls to render() overwrite each other?

When you call render() in a controller, the function is only executed once and then it exits. No other code in the PHP Controller will execute after the call to render(), so it is not possible for ...
hotwebmatter's user avatar
  • 3,050
1 vote

redirect my apache index?

I went with a change in /etc/apache2/sites-available Works good thanks! Here is some shortcuts for future reference. pi@raspberrypi2 /etc/apache2/sites-available $ apache2 default Usage: apache2 [-...
Jake's user avatar
  • 96
1 vote
Accepted

redirect my apache index?

NEW ADVICE: This tutorial should help you to change the DocumentRoot of your website by using Apache2 Virtual Hosts. The focus of the tutorial is on how to host more than one domain or subdomain on ...
hotwebmatter's user avatar
  • 3,050
1 vote
Accepted

What's is wrong with this php code

echo("</tr>") not properly terminated.
DinoCoderSaurus's user avatar
1 vote
Accepted

Encrypted passwords in POST method

Q: When should I encrypt passwords? A: Always, and as soon as possible. Whenever a user enters sensitive information like a password, you should immediately encrypt it using a one-way hash function ...
hotwebmatter's user avatar
  • 3,050
1 vote
Accepted

C$50 Finance Pset7 - Buy.php not INSERTing shares correctly

Learn something new every day! From the manual: With ON DUPLICATE KEY UPDATE, the affected-rows value per row is 1 if the row is inserted as a new row, 2 if an existing row is updated, and 0 if an ...
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,050
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,376
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,376
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.7k
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.7k

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