DirectPHP - FAQs, Troubleshoot and Tips & Techniques

This is the FAQ for the DirectPHP plugin.

Troubleshooting

  1. Q: My PHP codes are not processed.
  2. A: Did you enable the plugin? Go to Plugin Manager and make sure the plugin is enabled.

  3. Q: My PHP codes disappeared after clicking Save or Apply.
  4. A: Have you applied the following tip: How to enter HTML tags, javascript and PHP codes in Joomla 1.5.8?

  5. Q: My PHP codes disappeared after clicking Save or Apply.
  6. A: Do not use the "source button" in TinyMCE.

    Just type the codes right inside TinyMCE in the default WYSIWIG (what-you-see-is-what-you-get) mode.

Plugin Conflicts

If you've tried all of the above, and it still does not work, it might be because of conflicts with some other plugins or modules. To ascertain this,

  • Please try the plugin on a fresh install of Joomla. This will allow you to know if the plugin works on your machine at all.
  • If the plugin works on your fresh install of Joomla, then you could try add in the rest of the plugins and modules one by one until you find the one that causes the conflict.

Comments   

+1 # murali ayyagari 2012-03-05 10:05
I have installed the plugin and is working with the examples you gave( simple php). I tried to insert code with php, html, and javascript and css. It is not showing any errors but on publishing it is just displaying the code only( except the php code ). How to correct it>
Reply | Reply with quote | Quote
+1 # kksou 2012-03-05 16:45
Hi,

Are you saying that the PHP codes are working, but not the HTML and javascript?

Regards,
/kksou
Reply | Reply with quote | Quote
0 # murali ayyagari 2012-03-07 11:38
I have worked it out. PHP, HTML, Javascript all are working. My only problem is that my form inserts the form data into mysql table.But that is not working. Any customization i have to do in Directphp.php file for the database related code to work.
Reply | Reply with quote | Quote
-2 # kksou 2012-03-10 20:32
Hi,

If it's standard PHP, it should work.

What is the code that you are trying to run? What is the error messages that you see on the screen?

Regards,
/kksou
Reply | Reply with quote | Quote
0 # frank the tank 2012-04-16 15:22
hi, will it work with sessions/ submitting forms ?
Reply | Reply with quote | Quote
-1 # hans_eat 2012-04-26 01:06
Hi kksou,

this is a great tool, which works really good for me! I just have problems getting javascript working.

The function need to be within and echo"", correct? Otherwise it displays the javasscript code, but doesn't run.

How do I need to place the javascript code correctly in order to be recognized as such by phpdirect? And how can I call the functions?

Thanks a lot! :roll:
Reply | Reply with quote | Quote
-1 # hans_eat 2012-04-26 01:09
Quoting hans_eat:
Hi kksou,
The function need to be within and echo"",


Sorry, it dropped the php tags in the post. I meant:

The function needs to be within and php start and end tags and 'echo " "', correct?
Reply | Reply with quote | Quote
-1 # Tom_P 2012-07-26 05:48
Hi, i am trying to install a latest events php file in a cusstom module, using bot_jcalpro_latest_events.php
All the events have been entered in the calendar and are visible on the website, but i can't get the php file to work in html. Am i using the right one, if so what am i doing wrong?
Reply | Reply with quote | Quote
0 # Berry G 2012-09-05 01:29
Hi there,

I installed DirectPHP on my Joomla! 1.5.22 site and tried it. Unfortunately it doesn't work. When I save the article, the is converted to ?-->. I activated the plugin and checked the TinyMCE settings to match the advised settings but still it doesn't work. How can I resolve this?
Reply | Reply with quote | Quote
-1 # Berry G 2012-09-05 01:31
Hi there,

I installed DirectPHP on my Joomla! 1.5.22 site and tried it. Unfortunately it doesn't work. When I save the article, the "" is converted to "?-->". I activated the plugin and checked the TinyMCE settings to match the advised settings but still it doesn't work. How can I resolve this?
Hope anyone can help
Reply | Reply with quote | Quote
-2 # Berry G 2012-09-05 01:36
Unfortunately my question is not clear because the php tags are removed when I post on this forum. I'm trying to say that the php tags are modified by addition of !-- The php tag then looks like this (without spaces) < !-- ? php
Hope my question is clear.....
Reply | Reply with quote | Quote
-4 # uzbaby 2012-11-04 20:16
Hello
please can anybody help me
I want to add some php code to new module but after adding the php code I see only THE CODE itself. What am i doing wrong?
Reply | Reply with quote | Quote
-1 # kksou 2012-11-04 20:39
Hi,

Based on your description, looks like you've only installed the DirectPHP module.

For the module to work, it needs the DirectPHP plugin available here: http://www.kksou.com/php-gtk2/Joomla/DirectPHP-plugin.php

Please install the plugin and test the plugin by creating a new article and entering the PHP code in the article. (please follow the instructions as outlined in the article where you download the plugin).

Once the plugin is working correctly, you can then test your code in the module.

Please give it a try one more time and let me know if it works, ok?

Regards,
/kksou
Reply | Reply with quote | Quote
-2 # haggisbasher 2012-11-14 08:02
Quoting Berry G:
Unfortunately my question is not clear because the php tags are removed when I post on this forum. I'm trying to say that the php tags are modified by addition of !-- The php tag then looks like this (without spaces) < !-- ? php
Hope my question is clear.....


I am also experiencing this problem. Is there a workaround?
Reply | Reply with quote | Quote
-1 # Berry G 2012-11-17 05:26
Quoting haggisbasher:
Quoting Berry G:
Unfortunately my question is not clear because the php tags are removed when I post on this forum. I'm trying to say that the php tags are modified by addition of !-- The php tag then looks like this (without spaces) < !-- ? php
Hope my question is clear.....


I am also experiencing this problem. Is there a workaround?


You can solve this by selecting "No Editor" in the Joomla General settings. Put the php-code in the article and save the article. Afterwards you can select TinyMCE again. But if you edit the page with php-code you must select "No Editor" again.
Reply | Reply with quote | Quote
+1 # Knowledge Explained 2013-04-16 10:33
Hello kksou, thank you for your plugin! I am having a weird problem with DirectPHP 2.5 under Joomla 2.5.7.

I edit my articles at the backend, and for most PHP code, if I embed it in an article and press save, it makes the backend crash. However, the article was saved correctly: it displays on the web and the and the embedded PHP works right.

I get the feeling that the process of saving the article is attempting to execute the embedded PHP snippets at that very moment, instead of just saving them as HTML or text. Could this be happening?

If it helps, I am using editor CodeMirror (code only, no WYSIWYG).
Reply | Reply with quote | Quote
+1 # kksou 2013-04-17 00:20
Hi,

As a test, can you switch back to the default editor that comes with standard Joomla installation and see if it's the same problem.

This will allow you to see if it's just CodeMirror giving the problem.

Does CodeMirror has a forum? If yes, maybe you can post the question there. Maybe there are already some solutions for that.

Regards,
/kksou
Reply | Reply with quote | Quote
-2 # Knowledge Explained 2013-04-17 02:12
Hello kksou. I have tried changing editor, but the same happens. Even when I select "no editor", which reduces input to a text box.

What happens is this:
- I copy the text to the input box
- I press save
- The page becomes blank
- I can still press "back" on the browser, and I get to continue working at the backend
- If I go to the web and see the article, it displays and its embedded PHP worked as expected.

If you need any more details, feel free to ask (maybe through email?)
Reply | Reply with quote | Quote
+2 # kksou 2013-04-17 02:27
Hi,

Please do one more test:

1) Uninstall DirectPHP

2) Enter some PHP codes in editor

3) Click save

Does it give any error?

If yes, it means there's nothing to do with DirectPHP. It's the editor problem.

Regards,
/kksou
Reply | Reply with quote | Quote
0 # Knowledge Explained 2013-04-17 15:14
So, I tried deactivating DirectPHP. I re-saved some articles that normally made the backend go blank, and they saved without problems. When re-enabling DirectPHP, saving them again with the exact same content produces the problem again.

It seems it only happens when DirectPHP is active.
Reply | Reply with quote | Quote
-1 # Knowledge Explained 2013-04-18 01:10
Hi kksou, finally I wrote a fix myself that has solved the problem.

At the beginning of onContentPrepare function I have added the following 2 lines:

if( !JFactory::getApplication()->isSite() )
return true;

This restricts PHP code evaluation to the site (and not the backend). So it seems that my intuition was right here: PHP was getting evaluated when saving the article! Hope you can fix it for next versions. And thanks for your help.

www.knowledgeexplained.com
Reply | Reply with quote | Quote
0 # kksou 2013-04-19 01:28
Hi,

Thanks much for sharing this!

It's strange, because no other users have encountered this before. You can try this on a standard Joomla template. Don't think by default the editor will run the plugins. DirectPHP is a content plugin. It should run only with content articles.

In any case, this is still useful knowledge to know. It will benefit other users if they encounter similar situation.

Thanks and Regards,
/kksou
Reply | Reply with quote | Quote
+1 # Knowledge Explained 2013-04-20 05:17
What made me think that, is that the crash didn't happen for all PHP code. Depending on what instructions I added to the article, it would crash or not. That's what made me suspect: For a content string, what difference would it make if my PHP is calling echo or JFactory? None. Unless the PHP insertions are getting treated as code instead.

But I may be wrong, of course. Just letting you know my thoughts on the crash.
Reply | Reply with quote | Quote
0 # chandler 2013-07-02 08:19
I am trying to run sql commands and none of them seem to work.
Something as simple as creating a table with one column in it. I am not getting any errors and I am able to connect to the database but I can't do anything else.
Reply | Reply with quote | Quote
+1 # kksou 2013-07-02 08:27
1) Try echo "test123" first. Does it work?

2) If yes, then trying echo some debugging messages to see at which point it doesn't work.

3) How do you know that you are able to connect to the database?

4) If you are able to connect to the database, then what is not working?

5) You might need to set error_display in php.ini to display error messages.

Regards,
/kksou
Reply | Reply with quote | Quote
+1 # chandler 2013-07-02 08:40
I added comments to the quote
Quoting kksou:
1) Try echo "test123" first. Does it work?
yes I have "Now is: " working

2) If yes, then trying echo some debugging messages to see at which point it doesn't work.

3) How do you know that you are able to connect to the database?
I was using "(mysqli_connect_errno())" to check for errors

4) If you are able to connect to the database, then what is not working?
This is the proverbial question. Unfortunately I am trying to teach myself php and sql so there is a little bit of a learning curve.

5) You might need to set error_display in php.ini to display error messages.

Regards,
/kksou
Reply | Reply with quote | Quote
-2 # George123456 2013-09-12 17:53
Quoting kksou:
Hi,

Are you saying that the PHP codes are working, but not the HTML and javascript?

Regards,
/kksou


Only your php example codes are working. My script, which generates dynamic html-content is not displayed.
Reply | Reply with quote | Quote
0 # kksou 2013-09-13 01:33
Hi,

Can you please email me the codes that you're trying to run?

Regards,
/kksou
Reply | Reply with quote | Quote
+4 # strategystar 2013-10-06 12:40
Hi, I am using your plugin for PHP code in a joomla article and it is working perfectly except one thing... the main navigation of the website is not showing on this page????
please see:
http://www.net-direct-marketing.com/index.php/ad-form
Any ideas as how to fix this or why it is happening?
Reply | Reply with quote | Quote
-1 # johnnybgoodwin 2013-10-22 14:41
Hi there
The plugin worked when I first installed it. Today it won't work. The .php script is shown in full in the content.
Using TinyMCE in Joomla 2.5.14 and PHP 5.3.
Like I said, it worked a couple of days ago. Nothing changed on the site....
John
Reply | Reply with quote | Quote
0 # Vikash 2016-04-27 11:33
i am using DirectPHP plugin in zoomla version 3.0
but when i create page by sppage builder and write php code . its not working . when i check code on browser in inspect element php code show in comment .\

please can you solve this problem i have very tried .

Thanks
vikash sharma
Reply | Reply with quote | Quote
+1 # kksou 2016-04-28 08:15
Hi Vikash,

The DirectPHP plugin is a content plugin. As the name suggests, it's for use within the Article component only (which is com_content). I wrote this plugin to run simple PHP commands from within an article. It's not designed to run in other components.

The SP Page Builder is a different component by itself. It does not know all the plugins out there, and naturally it will not run DirectPHP plugin which is a content plugin.

You might want to check with the developer of SP Page Builder to see if there's anyway to trigger content plugin from within their component.

Warm Regards,
/kksou
Reply | Reply with quote | Quote
+2 # Bryan 2016-05-08 09:18
Hello. Always used your useful plugin. But after aupdate to Joomla 3.5.1 it stop working. Get error: Parse error: syntax error, unexpected '}' in Z:\home\test\www\plugins\content\DirectPHP\DirectP HP.php(58) : eval()'d code on line 16

But I nothing changed in code, just update Joomla.

My code is:


Notice: Undefined variable: colorbgsoon in Z:\home\test\www\plugins\content\DirectPHP\DirectP HP.php(58) : eval()'d code on line 1

Check my code on http://sandbox.onlinephpfunctions.com/ and it still working without errors.
Reply | Reply with quote | Quote
-1 # Ruediger 2016-07-05 10:52
Hello,

I am (still) using this wonderful little tool in various projects to add php into content - as said before, I really like it!!!

However, for your info, just in case you did not yet notice the following DEPRECATION message (on PHP 7.0.7):

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; plgContentDirectPHP has a deprecated constructor in ....httpdocs/plugins/content/DirectPHP\DirectPHP.p hp on line 23
Reply | Reply with quote | Quote
+1 # kksou 2016-10-14 07:38
Hi Ruediger,

Thanks to informing me about this way back in July. It's very nice of you!

For your info, have released DirectPHP for php7: New version of DirectPHP - support for PHP 7

You can download it here: http://www.kksou.com/php-gtk2/joomla/directphp-plugin.php#download

Thanks for your long-time support for the DirectPHP plugin!

Warm Regards,
/kksou
Reply | Reply with quote | Quote
+4 # Pete 2016-07-07 19:50
Installed fine, works great.
Why can't everything be this simple?
Can't find a 'donate' link.
Reply | Reply with quote | Quote
+1 # Iddy 2016-08-22 12:26
Hi, I'm using php direct in joomla 3 article to get data from database table. It pulls all the data correctly but there are joomla shortcodes that just display as shortcodes and don't convert.

If I run the php outside of joomla and then copy/paste the page directly into joomla article the shortcodes work. Any ideas?
Reply | Reply with quote | Quote
0 # Ruediger Schultz 2016-10-17 12:20
Hello Iddy,
I am a longterm (very happy) user of "DirectPHP". However for getting data out of your database and embed them into articles, you may want consider my own Joomla extension jDBexport. This is a data reporting tool, where you define SQL queries in the backend, and receive the results as Excel documents (or embed them in just about any way you want).
contact me if you like to know more...
regards Ruediger
Reply | Reply with quote | Quote
-1 # Sven Kutz 2018-03-09 12:03
Hi there,
I am using your DirectPHP Plugin and it worked all fine so far. Thanks so much for providing this Plugin. However, I have no experienced a problem with PHP Mail function. Within an article I have implemented code to generate an email and send it out via Mail(). Once processing the script, nothing is happening. I am not receiving any error message, but an email has also not been sent. First I thought it could be a missing email address which I have taken out from an mysql table, but I checked this and the query worked fine and e-mail address ist correct.

Do you have any idea what the problem could be? Just for your information: The DirectPHP Plugin is ordered before the Content - Email Cloaking.

Many thanks in advance for your support.
Reply | Reply with quote | Quote
+1 # kksou 2018-03-11 01:49
Hi Sven,

There's no way to fix anything if you don't know exactly what's the problem. So first thing first, you need to find out what is the error message.

Joomla has no inherent debugging tool. So the only way is to enable error_display in PHP and see what exactly is the error message produced.

Also DirectPHP uses standard eval() function. So you can also copy and paste the entire code into a standalone .PHP file and see if it runs from browser or command line. If it doesn't, you can see exactly what's the error message on the screen.

You may also want to refer to the following article that I've written that contains more details:
How to debug PHP codes in DirectPHP


Hope this helps.

Warm Regards,
/kksou
Reply | Reply with quote | Quote
-1 # Serge 2018-06-09 22:26
Hello !
Just confirm your plugin works perfectly under latest Joomla 3.8.8 and PHP 7.0. Thank you !
The only very desired feature is to enable this plugin for specific categories IDs or specific article IDs.
It would decrease a general article loading weight and increase the general safety.
With hope to a next update !
Best regards,
Reply | Reply with quote | Quote
-2 # Uwe Klaus 2018-11-28 06:48
Hello,
i'm working with directphp in Joomla 3.9.1 now and it is working fine :-) . I use codemirror as editor, because tinymce is a pain with a lot of php code - if you want to paste or press the wrong button.
:-) I use also php-rgraph which is a very nice tool to show my weather data graphically.
:sad: I had to reinstall my server and got updates on joomla, and other plugins...
Since that php commands do not work anymore within the {rgraph ....} tags ...
E.g.: {rgraph ... ymin="" ... } is totally ignored.

Any suggestions? Please help if you can. :-?
Reply | Reply with quote | Quote
-1 # kksou 2018-11-28 07:16
Hi Uwe,

Please take a look at the article
Ordering of Joomla plugins


Try to change the order of plugin so that you process DirectPHP before the php-rgraph plugin. I think the current order is such that php-rgraph is processed first followed by DirectPHP. That's why the php-rgraph tag is not processed.

Please give the above a try and let me know if it works.

Warm Regards,
/kksou
Reply | Reply with quote | Quote

Add comment


Security code
Refresh