2

I have a file, manage.php, which contains php code, as depicted below.

Other files are working fine on the same PC and same server (I use WAMP). And the code is working correctly interacting with MySQL databases for a login mechanism on another page...

For some reason the code is not rendered in either FF or Chrome. In chrome, as you can see, the code gets commented out by html comment blocks and nothing prints or is read, etc. I did not write the code like that in my text editor.

I am frustrated. Any ideas?

http://captainscall.site11.com/temp_stuff/why-php.PNG

Here is the full script for manage.php:

<?php 
/*
    /admin/index.php
    admin area for Neos Massage
    Made by Douglas Franz, freelance PHP/MySQL/HTML/CSS/JS/jQuery-ist.
*/

session_start();
include('models/auth.php');
include('includes/database.php');
?>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Neos Massage Admin Area</title>
    <script type="text/javascript" src="js/jquery.js"></script>
    <link rel="stylesheet" type="text/css" href="css/admin.css" />
    </head>

<body>

    <div id="admin_header"> 
        <img src="../images/header-background-restored-flower-no-color.png" style="vertical-align: top;"/>
        <span><b>Admin Area</b><br /><?php if (isset($_SESSION['uName'])) { echo $_SESSION['uName']; } ?></span>
        <div id="border">
        <img src="../images/border.png" width="100%" height="20"/>
        </div>
    </div>  

    <div id="admin_content">

        <h1 style="color: #402d11;">Neos Massage - Manage</h1>
            <hr />
            <a href="index.php?logout">logout</a>
            <br />
            <?php var_dump($_SESSION); echo "this is a test"; ?>
            <?php print "this is a test"; ?>



    </div>


</body>
</html>
khaverim
  • 3,386
  • 5
  • 36
  • 46

3 Answers3

3

Wow. Okay, so to diagnose it I copied the code in the file and then deleted manage.php altogether.

I then created a new file using the Windows Explorer GUI (the 'normal' way) called manage.php and pasted the code.

Then it worked.

Before I had created manage.php with Windows PowerShell using

new-item -type file manage.php

I have had similar problems where the encoding of PowerShell is not UTF-8 but Big-Endian or something and it...simply put, messes with things. I suppose this is a rare problem but a good lesson in diagnosing problems.

Thanks guys.

khaverim
  • 3,386
  • 5
  • 36
  • 46
2

This is definitely not a browser issue: it's an environmental one. Something in WAMP is not set up to execute this page as a PHP script.

David Kiger
  • 1,958
  • 1
  • 16
  • 25
  • is not being commented out correct? then this is wrong – iAmClownShoe Feb 26 '13 at 21:00
  • @David Kiger: yeah. But it is indeed only this page. Other pages are fine. I do not know why. The only thing I can think of right now is that I created the file through Windows PowerShell instead of the GUI and so it may have messed up the encoding and the server isn't recognizing it as a PHP file.. iAmClownShoe: that is also being commented out, yes – khaverim Feb 26 '13 at 21:01
  • @iAmClownShoe See his earlier comment. All PHP is unrendered on this page. – David Kiger Feb 26 '13 at 21:02
  • 2
    @khanahk Try using a simple text editor or IDE to create the file – Asad Saeeduddin Feb 26 '13 at 21:02
  • @Asad: yep. Just did it, and it worked that way (see my answer) – khaverim Feb 26 '13 at 21:06
1

If what you are saying is true, that other *.php files run without a problem, my assumption would be that the encoding you are saving the file in is causing the problem.

<!--?php <- What Chrome is changing the PHP tag to make me think the encoding of the document is incorrect.

Try saving the file as a new document, or copy and pasting the code into a new document and saving it as a new file. I would bet that fixes your issue.

Michael Irigoyen
  • 22,513
  • 17
  • 89
  • 131