Hi,
My current views has the the following sql query:
SELECT node.nid AS nid,
RAND() AS _random
FROM node node
LEFT JOIN node_revisions node_revisions ON node.vid = node_revisions.vid
WHERE UPPER(node_revisions.body) = UPPER('song')
ORDER BY _random ASC
I would like to use Views PHP filter to add the "LIMIT 3" to limit only 3 filtered records, the coding I put in Views PHP filter is as follows:
$result = db_fetch_array(db_query('SELECT node.nid AS nid,
RAND() AS _random
FROM node node
LEFT JOIN node_revisions node_revisions ON node.vid = node_revisions.vid
WHERE UPPER(node_revisions.body) = UPPER('song')
ORDER BY _random ASC LIMIT 3');
return array($result['nid']);
But it returns with error, could you advise what is wrong. Thanks.
Comments
Comment #1
gnassar commentedSorry, I don't troubleshoot others' PHP code, unless there is an error in the module itself.
Is there any reason you would think the module is at fault? SQL strings work fine here.
Comment #2
babymission commentedThis is the error message I got:
* warning: Cannot modify header information - headers already sent by (output started at /var/www/drupal/sites/all/modules/viewsphpfilter/views_handler_filter_node_nid_php.inc(48) : eval()'d code:8) in /var/www/drupal/includes/common.inc on line 141.
Fyi, I put the script (the SQL script) in Mysql via Phpmyadmin, and it works and returned the right results. That's why I wondered if there is anything wrong with this module, I just want some guidance from you if my understanding is wrong....Please advise. Thanks.
Comment #3
gnassar commentedAs the message says, that is not an error. It is a warning. The warning indicates that though the module is working fine, as the error refers to the "eval()'d code." Most often, one will get this message when there is some sort of error in the PHP code they're using.