• I have tried several ways of adding the following code below to my pages but have not been able to get the page to display correctly. I have tried various php plugins like exec-php, php exec and many others to no avail. Can anyone give me any insight on what I am doing wrong with the code below. I am basically placing the code inside a new page or post, but when i click to display, it shows the code instead of the store which is what the code is for?

    <?php
    $SID=”02486A4A-7C45-4014-825D-B0789249A909″;
    $IPAddress = urlencode($_SERVER[‘REMOTE_ADDR’]);
    $UserAgent = urlencode($_SERVER[‘HTTP_USER_AGENT’]);
    $Host=urlencode($_SERVER[‘HTTP_HOST’]);
    $PageURL=urlencode($_SERVER[‘SCRIPT_NAME’].’?’.$_SERVER[‘QUERY_STRING’]);
    $URL=”http://si.goldencan.com/GetData.aspx?ver=2.0&SID=&#8221;.$SID;
    $URL=$URL.’&Host=’.$Host;
    $URL = $URL.’&PageURL=’.$PageURL;
    $URL = $URL.’&IPAddress=’.$IPAddress;
    $URL = $URL.’&UserAgent=’.$UserAgent;
    include($URL);
    ?>

Viewing 4 replies - 1 through 4 (of 4 total)
  • You can’t place PHP code within a post without a plugin. You either need to obtain a plugin that allows PHP to run from within a post, or write a function and apply the function to the template file.

    Thread Starter ubailey79

    (@ubailey79)

    I have tried several different php plugins while running this script and it still does not work.

    I don’t understand “while running this script”? If you’re popping PHP code into a post as content, here is no “running this script”. PHP code *will not run* if you insert it as text in the body of a post. You have to get a plugin and allows PHP code to run when it is content in the body of your post, and you have to read the instructions for the plugin to see how to activate the sections of code that should run. (i’s not as simple as install and activate – some of them require the use of tags to differentiate between text and code that should be processed).

    But just popping code into the body of a post won’t work – it’ll output it as straight text unless you use a plugin, or write your own code in your functions.php file that pops it in.

    Thread Starter ubailey79

    (@ubailey79)

    I figured it out. I copied my page.php template and created a new template with the code inserted there. I then created a blank wordpress page using the new template and now the code works. Thank you very much for your help on this. I had been struggling with this for quite some time.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Adding php script’ is closed to new replies.