Reputation: 489
I'm having a little problem with this MySQL query. I've already used an suggestion I've seen in another question but still doesn't work....
Here's the code
$kernel->db->query( "UPDATE `" . TABLE_PREFIX . "users`
SET `total_downs` = `total_downs` + 1
WHERE `phcdl_files`.`file_author` = " . $file['file_author'] );
Which gives
Invalid SQL Query
Unknown column 'phcdl_files.file_author' in 'where clause' (MySQL error no; 1054)
Upvotes: 0
Views: 24050
Reputation: 268
where is phcdl_files
.file_author
?
"UPDATE `" . TABLE_PREFIX . "users`
SET `total_downs` = `total_downs` + 1
WHERE `user`.`file_author` = " . $file['file_author']
and $file['file_author'] should come from phcdl_files table
Upvotes: 0
Reputation: 5589
That means that the column file_author doesn't exist in the table phcdl_files. You probably want
$kernel->db->query( "UPDATE " . TABLE_PREFIX . "users SET total_downs = total_downs + 1 WHERE file_author = " . $file['file_author'] );
EDIT: please see the comment by Byron Whitlock above. You generally don't want to insert a variable directly into a SQL query string.
Upvotes: 5
Reputation: 16708
If phcdl_files
is the name of a table, you need to include that table in your query, and express some relationship between it and the rows in TABLE_PREFIXusers
that you want to update.
Upvotes: 1