Hot answers tagged

6 votes
Accepted

Pset7 missing mysql sock

I'm sorry if it's not appropriate to answer your own question but I'd like to post the solution to this problem just in case someone has the same issue. The commands sudo /etc/init.d/mysql start ...
user avatar
  • 97
3 votes
Accepted

Pagination using mysql and php

Yes, there are many solutions. If with "recent entries" you mean "sorted by date" (or with sequential indexed IDs), all you need to do is : Define a variable called $last_id = 0; Use a SELECT ...
user avatar
  • 1,156
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 ...
user avatar
  • 3,036
3 votes
Accepted

How do I check if an email adress is already used in mySQL?

Your current query will return FALSE if it failed and return data in the form of rows if succesful. You know there can only be one match in the database, if any, but the query function does not know ...
user avatar
  • 1,317
3 votes
Accepted

What is wrong with this SQL command?

As I told you on Slack: This is the syntax that will work: "INSERT INTO table(field1,field2,field3) VALUES (?,?,?)", $var1, $var2, $var3); and replacing the fields and variables as appropriate.
user avatar
  • 18.4k
2 votes
Accepted

(pset8) Search.php FULLTEXT minimum character length

I'm not so sure you should create distinctive indexes for each column. What I did was to create a FULLTEXT index for 3 columns together, and then search using that. If you want to create different ...
user avatar
  • 7,326
2 votes
Accepted

How to change mysql minimum-character length

This post sounds like it might be what you are looking for Match TWO letters with SQL query… cd to /etc/mysql/conf.d and create a file with extension .cnf (e.g. user_sett.cnf) that looks like this:...
user avatar
2 votes
Accepted

Why can't I make this table? It shows an error

The problem looks like you are trying to create a table with two primary keys, one on column ID and one on column TIMESTAMP. A table is only allowed to have one primary key. You can have multiple keys,...
user avatar
  • 64.2k
2 votes
Accepted

Pset 8 Error CS50 Library SQL (CS50 IDE)

it appears that you're using a database user called TODO instead of the one that you should be using. recall that you need to specify these settings in a file called config.json!
user avatar
  • 17.4k
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 ...
user avatar
  • 17.4k
1 vote
Accepted

Pset7 (Movies) 12.sql: Table outputs 96 rows rather than 5 rows

Using a previous post on this forum, I was able to deduce I had to use the INTERSECT operator, which instantly solves the problem.
user avatar
1 vote

Where is the syntax error in this sql file?

Unless I'm missing something, that is not a sql query. A sql query is something like "SELECT columns FROM table WHERE condition". That is html code.
user avatar
1 vote

Locked out of phymyadmin

This seems to have resolved itself by restarting the development environment.
user avatar
1 vote
Accepted

Duplicate entry Error when inserting into portfolios pset7

OK... looks like there is a quick fix this that it was not implicit in the description. By adding ALTER TABLE yourtablename ADD CONSTRAINT uq_yourtablename UNIQUE(column1, column2); it seems that the ...
user avatar
  • 25
1 vote
Accepted

pset7: query(INSERT) return value?

You are not calling PHP mysql_query(). You are calling CS50::query. From the pset specification/instructions: If query is instead passed a DELETE, INSERT, or UPDATE statement, it will return a non-...
user avatar
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 ...
user avatar
1 vote

pset7 problem with buy and portfolios table

Without seeing the details of your user table, or knowing if you have any foreign keys to that table, I can't be sure, but I'm fairly confident that your problem is in your primary key. I'm guessing ...
user avatar
  • 64.2k
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 ...
user avatar
1 vote
Accepted

MySQL Query function not working

$username is blank as per the error message: Access denied for user ''@'localhost'..... . There is nothing between the two ticks (single quotes) after user. That makes $password, $dbname suspect as ...
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 ...
user avatar
  • 17.4k
1 vote

I can't access my table in phpMyadmin

I had this same problem and did find a resolution. After trying numerous suggestions and trying to recreate missing tables, it just went from one problem to another, without ever getting to a ...
user avatar
  • 64.2k
1 vote

SQL Order results by score, desc

Never mind, got it. It is SELECT * FROM users ORDER BY score DESC
user avatar
  • 1,211
1 vote

Mysterious MySQL changes

The minute I post this I find the /home/jharvard/logs/mysqld directory with the queries.log file... :P tail -F on that one solves my problem! :)
user avatar
1 vote

The code given in cs50 doesn t work

Check your table structure with phpmyadmin: there should be an index id_symbol of type BTREE unique not null.
user avatar
  • 1,156
1 vote

Accessing information from PHPmyadmin using Javscript

This is the answer from Kareem's link. Please do not vote on this. I just want to take this answered question out of the unanswered list. There are actually several approaches to do this. Some ...
user avatar
  • 1,211
1 vote
Accepted

Foreign key constraint error when linking ID to users table

The immediate problems here are in the INSERT statement. You're trying to add two rows to the table, and the first row has no values. So what user does it belong to? The foreign key constraint on this ...
user avatar
  • 2,136
1 vote
Accepted

Unknown column cash php?

You need to make sure you have added the column cash to the users table as described in the pset 7 specification: Okay, let’s give each of your users some cash. Assuming you’re still on ...
user avatar
  • 2,136

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