Hot answers tagged

3 votes

PSET 7 Index.php Fatal error: Call to undefined function query()

query() is defined in the CS50 PHP library, so you need to put CS50::query(whatever) instead of just query. PHP isn't quite as smart with included libraries as C is apparently. :)
Fobok's user avatar
  • 82
2 votes
Accepted

pset6 How to tackle check50 on .php?name=Alice

The strtok() call here: char* absolute_path = strtok(req_tar, "?"); will crop req_tar at the ? and make it always be equal to abs_path. Because of this, the following condition will never be true ...
Yuri Laguardia's user avatar
2 votes
Accepted

Pset7: Undefined offset in register.php

Look carefully at this line: $_SESSION[$id];. Remember it is $_SESSION["id"] that controls whether a user is logged in or not. This if ($result === false) is also a problem. Since the select query ...
DinoCoderSaurus's user avatar
2 votes
Accepted

PSET8 - MASHUP : Can't find FULLTEXT indexes when using WITH QUERY EXPANSION

It is very weird but I advice you to follow these steps: Use ALTER TABLE <table> ENABLE KEYS to make sure that your keys are active. If nothing's still working, use ALTER TABLE <table> ...
DFATPUNK's user avatar
  • 155
1 vote
Accepted

Check if query returns empty value

db.execute always returns an array, you can always print to the console to see its content, if your intention is to debug. If what you want is to warn the user, simply check that result is not null ...
MARS's user avatar
  • 5,169
1 vote
Accepted

CS50 Understanding Technology Progress

Patience, young grasshopper. Certificates are processed once a month, during the first week of each month. It sounds like you missed the last run. If you don't have it by Mar. 10, then contact staff. ...
Cliff B's user avatar
  • 68.3k
1 vote

SQL SELECT query

It will return a list of dicts. Each dict item contains a key:value pair, where the key should be the same as the keys in your portfolio table (ex. symbol, stockname, price) and the value being values ...
tishihar's user avatar
1 vote
Accepted

PSET6 Parse Segmentation Fault

When you declare a string literal, as with char* php = "";,it is stored in read-only memory. So it is indeed seg-faulting here strcpy(php, path); because it cannot change read-only memory. Even if ...
DinoCoderSaurus's user avatar
1 vote
Accepted

pset7 sell.php I seem to be missing something

It is right. CS50::query() always returns an array of rows, even when the result is just one row. That's why you should use the [0], as you have correctly done. You can ctrl+F this: // first (...
Yuri Laguardia's user avatar
1 vote
Accepted

Difference between CS50::query() and query()

When you are using CS50 IDE with inbuilt CS50 SQL library files then it's easier to use CS50::query() function. In normal situations, eg in a linux machine, you can use only the query() function. ...
Akshay Sreekumar'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

Pointer to char comes back empty

Scope. Pointers. Look at the difference between the way you create abs_path and the way you create query. This strncpy(abs_path, reqtar, aplen); changes the contents of the memory that abs_path points ...
DinoCoderSaurus's user avatar
1 vote
Accepted

Help needed with query code for pset6

a string is an array of characters and, in C, an array has fixed length. that is, once the length of an array is determined, it cannot change. you are declaring the string query to be of length 1 ...
kzidane's user avatar
  • 17.7k
1 vote
Accepted

pset7 sell controller issue: undefined index

This means that $positions array don't have the key value in it. Check isset($positions["value"]) before hand.
Aboalnaga's user avatar
  • 189
1 vote

PHP Fatal error: Column 'country_code' cannot be nullPHP Fatal error: Column 'country_code' cannot be null

You will get this error PHP Fatal error: Column 'country_code' cannot be null in /home/jharvard /vhosts/pset8/includes/functions.php on line 57 if you use while(!feof($yourfile)) to iterate ...
DinoCoderSaurus's user avatar
1 vote

PHP Fatal error: Column 'country_code' cannot be nullPHP Fatal error: Column 'country_code' cannot be null

How are you getting the data from the csv file and populating $file and, by extension, $row? I would start by doing a dump of $row just before the query. I suspect that there is no $row[COUNTRY_CODE],...
Cliff B's user avatar
  • 68.3k
1 vote
Accepted

pset8 query function

$lines[12] doesn't exist on $lines as return value from fgetcsv...get rid of "id" as one of your insert values – Mauricio Aguilar Cardenas 7 hours ago Thanks, this has worked. Data seems to stop ...
Cliff B's user avatar
  • 68.3k

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