PHP code suddenly appears on my webpage, but not executed - did not do this before?

Blocks or snippets of PHP code appear on my web page suddenly, as if they were not recognized as PHP code. I have worked on this before, and I can’t think of anything that I changed or did, it would stop him from working! I spent so much time for Apache, MySQL, and PHP to work together in the first place, and now that. I am ready to tear my hair!

Example 1: Example 1 Example 1: (note that on the web page one block of php code is displayed, and the other is not!)

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

Example 2: Example 2

Code Example 2:

 <fieldset> <legend>Tags:</legend> <table class="tagstable"> <tr class="tagsrow"> </tr> <?php $query = "SHOW COLUMNS FROM recipes LIKE 'Tags'"; if (!($ret = mysql_query($query))) die("Error - could not show columns: " . mysql_error()); if(mysql_num_rows($ret)>0){ $row=mysql_fetch_row($ret); $options=explode("','",preg_replace("/(enum|set)\('(.+?)'\)/","\\2",$row[1])); } foreach ($options as $tag) { echo '<script type="text/javascript">addTag("' . $tag . '", false)</script>'; } ?> </table> <br> <input type="text" id="addtag"><input type="submit" value="Add"> </fieldset> 

Troubleshooting:

  • My phpinfo (); page works as expected
  • The folder containing php.exe is included in my PATH
  • Apache trial restart
  • Follow all steps in answering 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 </IfModule> AddType application/x-httpd-php .php PHPIniDir "C:/websites/php" 

Anything left that I didn’t think of?

Thanks!

+8
html php mysql apache
source share
1 answer

What is the path to the phpinfo () page? Compare this to what you use to access your script. My guess (when you say that "php.exe is included in my PATH") is that you are not accessing the file in your web root, but are trying to directly access it through the file system. You need to access it through the web server. If you do it right, it will probably look like this:

 http://localhost/myscript.php 
+3
source share

All Articles