Shortcode Exec PHP
[resolved] Including MySQL-Query destroys theme (3 posts)

  1. Sebastian
    Posted 4 years ago #

    Hi there, at first thank you very much for this fantastic and necessary plugin! Actually everything works fine. ;D

    Beneath other scripts I do include (via require_once) an external php-file with some variables and for one variable (the date) I ask the database to give me the information and write it into the variable. For this db-query I add this:

    error_reporting (E_ALL);
    $connection = mysql_connect ("localhost","database", "password") or die ("no connection");
    mysql_select_db("table") or die ("doesnt exist");

    Wenn I push the "test"-button in the plugin the results are correct (!). BUT when I publish the article some other theme-parts (from other plugins) are broken. When I delete the 2nd line (mysql_select_db("table")), it works again (for sure without the date), but it works fine. So what's the matter with the database-inclusion? What I made wrong? Or HOW to include some database-entries?


  2. M66B
    Plugin Author

    Posted 4 years ago #

    I have no idea what is going wrong, but maybe you should try the standard WordPress database functions to prevent interfering with the WordPress framework. Don't forget to do a global $wpdb;.

  3. Sebastian
    Posted 4 years ago #

    I got it... As it's mentioned here you need to add a "TRUE" if you use the same connection.

    So it should look like this (compare to code above):

    error_reporting (E_ALL);
    $connection = mysql_connect ("localhost","database", "password", TRUE) or die ("no connection");
    mysql_select_db("table") or die ("doesnt exist");

    Topic resolved.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Shortcode Exec PHP
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic