I just installed Drupal for the first time today, though I'm familiar with Wordpress. I'm relatively new to PHP and SQL queries, so I'm sure I'm doing something dumb, but after almost 5 hours of searching and trying different things, I can't seem to figure this stupid thing out.
Initially, I just wanted to query my database and pull out a specific value from a table then run an IF/THEN check against it. I couldn't get that to work, so I eventually dumbed it down to the most simple code I could possibly find. I am pasting the following code into a recently created 'basic page' node with PHP Code format selected:
$results = db_query("SELECT nid, title FROM {node}");
Hello, world
From what I've read, that code should just return the node ID and node Title from each row in the {node} database, followed by Hello, world. When I run that code, the only thing I'm seeing is Hello, world -- nothing is returned from the PHP code.
I've tried changing it to:
$results = db_query("SELECT nid, title FROM {node}");
echo $results;
But that breaks the page and returns 'The website recovered from an unexpected error, please try again later.'
$results = "PRINT RESULTS, DAMMIT!"
echo $results;