Home » Php » mysql – PHP code is suddenly showing up in my web page rather than executing – wasn't doing this before?

mysql – PHP code is suddenly showing up in my web page rather than executing – wasn't doing this before?

Posted by: admin July 12, 2020 Leave a comment


Blocks or pieces of PHP code are showing up in my web page suddenly as though they are not being recognized as PHP code. I had it working just find before and I can’t think of anything I’ve changed or done that would have stopped it from working! I spent so long getting Apache, MySQL and PHP working together in the first place and now this. I am ready to tear my hair out!!

Example 1:
Example 1
Example 1 code:
(note that one php code block is showing up in the web page, while the other is not!)

    <legend>Enter SELECT statement:</legend>
    <textarea name="select" style="width: 100%; margin-bottom: 10px;">
            if (isset($_POST['select'])
                echo $_POST['select'];
    <input type="submit" value="Search" />
    <!-- display any sql errors here -->
        echo "hello world!";
        if (isset($_POST['select']) {
            if (!$results = mysql_query($_POST['select']))
                die("Error: " . mysql_error());

Example 2:
Example 2

Example 2 code:

    <table class="tagstable">
        <tr class="tagsrow">

            $query = "SHOW COLUMNS FROM recipes LIKE 'Tags'";
            if (!($ret = mysql_query($query)))
                die("Error - could not show columns: " . mysql_error());


            foreach ($options as $tag) {
                echo '<script type="text/javascript">addTag("' . $tag . '", false)</script>';
    <input type="text" id="addtag"><input type="submit" value="Add">


  • My phpinfo(); page works as expected
  • Folder containing php.exe is included in my PATH
  • Tried restarting Apache
  • Followed all steps in the answer to this question
  • Using Apache 2.2.22, MySQL Server 5.5.24, PHP 5.4.3, Windows 7

Apache httpd.conf contains:

LoadModule php5_module "c:/websites/php/php5apache2_2.dll"
<IfModule dir_module>
  DirectoryIndex index.html index.htm index.php
AddType application/x-httpd-php .php
PHPIniDir "C:/websites/php"

Anything left that I haven’t thought of??

Thank you!

How to&Answers:

What’s the path to the phpinfo() page? Compare that to the path that your using to access your script. My guess (by when you say that “php.exe is included in my PATH”), is that you aren’t accessing the file in your web root, but rather trying to directly access it through the file system. You need to access it through the webserver. If you do this right, it will probably look like: