Is it possible to use php in the database table

Closed due to the fact that the essence of the question is not clear to the participants of fori1ton , Pavel Mayorov , ixSci , Nofate 18 May '15 at 9:43 .

Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .

    5 answers 5

    Well, in principle, it is possible, if you later run this variable, and not just print it out. Prompts an example

    $d=" mt_srand(time());\$max=10; \$a=array(6,3,2,2,2,5); print_r(\$a);"; eval($d); 

    The $ d variable gets the code from the database. Remember that the code must be pure pkhp. And second! Escaping should already be. That is - screening quotes and dollar signs.

      The database can contain anything, you can shove the entire site into the database))

      By the way, the story from the fiction section:

      Data:
      Hosting with 1mb memory
      Database server with 500MB of memory

      Purpose:
      Place your website on hosting

      Decision:
      Fill the entire site in the database, more or less structurally distribute data across the database.
      We write index.php with a set of queries to the database.

      ps
      The database should only store data that can somehow be changed (settings, information, users, etc., as in Jumla, for example)
      It is also acceptable to keep lists in the database that do not change but are very long.
      The structure of the application should not fall into the database, the structure is reflected by a set of tables and their relationships

        As an option - to encode the code you need with the function base64_encode , write the result to the database, and execute it like this:

         $execCode = 'код из базы данных'; eval ( base64_decode( $execCode ) ); 

        But it is better not to do so.

          It is possible, if in the form of text. The database will not understand php-functions and will not execute.

          TC - if you really plan to implement something in this way, and not just out of interest, then you are obviously moving in the wrong direction. So, of course, you can do it, but do not do it.