I searched and failed, Please give me an example on what code to input inside..

Another Question:
Can I query the database and return values?

Actually, I already did that and what a surprise! It destroyed my drupal, so I removed the field manually in the database also truncated the cache table where it was being saved automatically. So, does inserting such database queries inside that "allowed values php code" field makes my drupal crash?

Comments

pkej’s picture

I should think there was a problem with your code, or how you wrote it into the field? Perhaps this article might be of assistance: http://www.lullabot.com/articles/drupal_input_formats_and_filters

PHP Evaluator: The PHP Evaluator is the most radical of all Drupal's core filters. It looks for text enclosed in ... and evaluates it as PHP code. This effectively allows you to program and extend Drupal just by submitting content to the site! In 99% of cases, this is a bad idea, and the initial attraction of harnessing such power should be weighed by a healthy sense of fear. If you really need to write PHP code to accomplish what you're trying to do, writing a module is usually a better idea (and not that hard in most cases). Furthermore, in the wrong hands, the PHP Evaluator is an enormous security risk. A malicious attacker, with the PHP Evaluator at their disposal, could wipe out your database and take control of your web server.

If you need to insert code there you should try out your code as a plain php file, just put it in the root of your drupal installation and point directly to it in the address field of your browser. If the code works in the PHP file, it will work in drupal.

For that excersize also look into bootstrap.inc, that's a way to include the Drupal API in a php file. (At least I think it was bootstrap.inc :)

Paul K Egell-Johnsen

Paul K Egell-Johnsen

webpoga’s picture

Thanks a lot! I guess it is my fault since I am not reading instructions carefully. It says there that I should not include , where I guess (because I don't actually remember) I put those. You reply explains it all.
Thanks.

dafa’s picture

My guess is - If you dont know what to put in there, dont use it.

It is for fairly advanced use...

--
dafa

mooffie’s picture

BTW, for practical examples, see:

Getting the 'allowed values' from a DB table, or from another node's body.

webpoga’s picture

Thanks! really appreciated it! bookmarked it for future use. Btw, tried them both and it works! Thanks!