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. :)
3
votes
Accepted
What does query function returns actually?
The function named query() returns an array of row where each element in that array is another associative array that forms a row.
When the following statement is executed, considering that username ...
2
votes
Accepted
Column count doesn't match value count at row 1
Edited original answer. You have your INSERT INTO syntax incorrect.
Syntax should be:
INSERT INTO tablename (Table Col1, Table Col2, etc.) VALUES (? marks for variables, static items enclosed in ...
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> ...
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 ...
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 ...
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 ...
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.
...
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 ...
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 ...
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 (...
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.
...
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 ...
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 ...
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 ...
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.
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 ...
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],...
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 ...
1
vote
Accepted
pset6 server.c extract query from request-target
I'd guess its because you're doing calloc(1,sizeof(char)) for request_arg_1. This happens again for query & will likely cause similar problems later.
By calling calloc(1,sizeof(char)), you're ...
1
vote
pset7: query function arguments
The /* ... */ is a comment.
You should insert your query string ($sql) into the query function.
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
query × 36pset7 × 13
pset6 × 9
pset8 × 6
server × 4
sell × 4
mysql × 4
sql × 3
mashup × 3
parse × 3
php × 3
finance × 2
segmentation-fault × 2
html × 2
search × 2
import × 2
cs50x × 1
check50 × 1
cs50-ide × 1
flask × 1
buy × 1
cs50-web-programming-with-python × 1
pset × 1
index × 1
register × 1