Hot answers tagged

6

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 sudo /etc/init.d/mysql stop sudo /etc/init.d/mysql restart solve the issue.


3

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 statement with a LIMIT clause (i.e. "SELECT * from Table where ID > $last_id order by ID LIMIT 20" for a 20 items page) Save the last ID in a variable ($last_id = $...


3

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 shell SHOW DATABASES; USE pset7; SHOW TABLES; DESCRIBE users; SELECT * FROM users; SELECT COUNT(*) FROM users; quit It's rock-solid and reliable, and it will ...


3

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 that. It returns all data the same, whether its 1 row or an array of many rows. As such, the rows returned must be accessed with an array index, just like an ...


3

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.


2

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 FULLTEXT indexes for each column (it could work I'm not sure) you could do it like that. Create your FULLTEXT indexes by going here, selecting all the columns you ...


2

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: [mysqld] ft_min_word_len=2 and save. Restart the server by rebooting the appliance and that should do it. I had a problem with permissions on /etc/...


2

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, they can be unique or not unique (referring to the column values), they can index the combined values of multiple columns, etc., but there can ONLY be one (or ...


2

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!


1

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 provided by the staff that handles that for you. luckily, this function uses PDO underneath the hood. for more information, see functions!


1

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


1

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.


1

This seems to have resolved itself by restarting the development environment.


1

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 problem is solved, this initially should do the trick. :-)


1

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-negative integer that represents the number of rows deleted, inserted, or updated, respectively.......... Note our use of IGNORE, which ensures that this ...


1

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 you have to define "relevance" to the computer, and then tell the computer how to apply that "relevance". Here's one possible approach, assuming "relevance" is "...


1

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 that the ID column is the userid and not a sequential ID number for rows in the table. If this is true, that means that this table only allows one row per user. ...


1

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 table to the pset7 database. You wouldn't have to change any config files or functions. (You'd have to modify pset8.sql for database name change). Adding the "...


1

$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 well. Also, check the variable name used in your close statement.


1

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 the contents!


1

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 satisfactory solution. Unfortunately, the best solution turned out to be the most drastic. The problem you have is that one or more tables that should have been ...


1

Never mind, got it. It is SELECT * FROM users ORDER BY score DESC


1

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! :)


1

Check your table structure with phpmyadmin: there should be an index id_symbol of type BTREE unique not null.


1

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 require more overhead than others, and some are considered better than others. In no particular order: Use AJAX to get the data you need from the server. Echo the ...


1

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 table requires all of its rows to have a "parent" user in the users table, and I'm pretty sure none of those users have '' as their ID. There are some other ...


1

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 phpMyAdmin’s Structure tab, you should see a form with which you can add new columns. Click the radio button immediately to the left of After, select hash from the ...


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