Convert .html to .php -> fail

i have a .html file as below which works fine when i run it in apache2 but when i change the file extension to .php file it cant work properly. Please suggest your idea. Thank you.

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=“http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=“Content-Type” content=“text/html; charset=utf-8” />
<title>Untitled Document</title>
<link href=“jquery.mobile-1.0/jquery.mobile-1.0.css” rel=“stylesheet” type=“text/css” />
<link href=“css/jqm-docs.css” rel=“stylesheet” type=“text/css” />
<script src=“jquery.mobile-1.0/jquery-1.6.4.min.js” type=“text/javascript”></script>
<script src=“jquery.mobile-1.0/jquery.mobile-1.0.min.js” type=“text/javascript”></script>

</head>

<body>
<div data-role=“page”>
<div id=“jqm-homeheader”>
<h1 id=“jqm-logo”><img src=“file:///C|/Users/Asus/Desktop/title.png” width=“1344” height=“111” /></h1>
<h1 style=“font-family:Tahoma, Geneva, sans-serif; color:#00F;”> Welcome to Student Online Progress Analysis System</h1>
</div>
<div data-role=“content” data-theme=“d”>
<ul data-role=“listview” data-filter=“true” data-inset=“true”>
<li data-theme=“d”>
<h3>Data Management</h3>
<p>All confidential data will kept in the server database and can be editted or updated only by administrator</p>
<ul data-theme=“d”>
<li>Key in new data
<ul data-theme=“d”>

        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;Update database
        &lt;ul data-theme="d"&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Chicken&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Cow&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Duck&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Horse&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Pig&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Sheep&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;View Record
        &lt;ul data-theme="d"&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Aardvark&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Alligator&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Ant&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Bear&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Beaver&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Cougar&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Dingo&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Eagle&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Elephant&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Ferret&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Frog&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Giraffe&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Lion&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Monkey&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Panda bear&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Polar bear&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Tiger&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Zebra&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;h3&gt;Colors&lt;/h3&gt;
    &lt;p&gt;Fresh colors from the magic rainbow.&lt;/p&gt;
    &lt;ul data-theme="d"&gt;
      &lt;li&gt;&lt;a href="index.html"&gt;Blue&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="index.html"&gt;Green&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="index.html"&gt;Orange&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="index.html"&gt;Purple&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="index.html"&gt;Red&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="index.html"&gt;Yellow&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="index.html"&gt;Violet&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;h3&gt;Vehicles&lt;/h3&gt;
    &lt;p&gt;Everything from cars to planes.&lt;/p&gt;
    &lt;ul data-theme="d"&gt;
      &lt;li&gt;Cars
        &lt;ul data-theme="d"&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Acura&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Audi&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;BMW&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Cadillac&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Chrysler&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Dodge&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Ferrari&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Ford&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;GMC&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Honda&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Hyundai&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Infiniti&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Jeep&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Kia&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Lexus&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Mini&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Nissan&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Porsche&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Subaru&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Toyota&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Volkswagon&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Volvo&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;Planes
        &lt;ul data-theme="d"&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Boeing&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Cessna&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Derringer&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Embraer&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Gulfstream&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Piper Aircraft&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Raytheon&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;Construction
        &lt;ul data-theme="d"&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Caterpillar&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Ford&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;John Deere&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

</div>
</div>
</body>
</html>

The widget works fine in .html extension and once i changed it to .php extenstion it can’t run.

By the look of your file paths (e.g. src="file:///C|/Users/Asus/Desktop/title.png") is seems you are running this page on your local machine. PHP won’t run on your local machine unless you have a server environment set up. That’s just a suggestion. There’s no actual PHP in that page, so maybe you should explain a bit more about what you are trying to do here.

Hye there,thanks for replying. Actually u can just ignore the picture path as it does not effect anything (forgot to delete it). Actually when i run this page in .html, if you can look through abit to this code there’s a button “data management” am i right? when i click on it, it will go to another page with “data management” as it title and 3 other choices below but when i tried to run it in .php and i click the “data management” button, nothing happened.I can’t really upload the output picture here and i don’t know why@.@ so i hope you understand my point.

when i click on it, it will go to another page with “data management” as it title and 3 other choices below

It doesn’t go to anther page, but the content on that same page is revealed by JavaScript (JS). None of that data stuff has anything to do with PHP—at least as far as your code goes. The paths to your JS sound like they are broken. Have you moved the .php version of the page to a different location from the .html version?

yes you are right. it does not go to the other page but the content on that same page is revealed by js. do i need to separate the .html version and .php version ?

i tried to move the .html version to other location but still the result is the same. about the broken link, how can i fix it?

After renaming your file with the .php extension, add this first line:



<?php /* dummy comment. */ ?>


u mean add it on the first line or anywhere in the code?

Make that your first line then the doctype, etc

i add simple php code (echo “hello”) at the very first line and run it but it didnt echo the words. the same page coming out

sorry but what is this “&/Lt;! Doctor html”?

Whoops sorry about that. This keyboard has a mind of its own.

I was trying to type the less than symbol and doctype.

You were too quick and read the first version :slight_smile:

I think that either there’s is an error in your script or apache, php/mysql is not installed.

Try this:

 
<?php echo 'hello sitepoint';

// no closing statement necessary


error would occured if didn’t put closing statement.

Back on my keyboard :slight_smile:

I make s special point not to have the closing PHP statement to ensure no white space errors occur.

Read the comments on this thread:
http://stackoverflow.com/questions/4410704/why-would-one-omit-the-close-tag

i understand what are you trying to say but the script which i posted works well in .hmtl extension and the thing is once i changed the extension without changing any of the code there’s some problem occured example like when i clicked certain button, it does not respond. Just like ralph.m said, the path to my js seems broken. i think thats the main problem now.

There could be numerous reasons why your PHP script is failing and as you mentioned that the javascript may be the problem. It could also be the it is a BOM file.

The code I supplied would prove that your Apache and PHP are set correctly. Try this and if there are any errors they will be displayed:



<?php
  error_reporting(-1); 
  ini_set('display_errors',1);

  echo 'Hello Sitepoint';


I prefer starting with some script that works then gradually adding more script then fixing the errors if and when they appear.

tried it already and no error comes out and the “Hello sitepoint” also not coming out. maybe because it direct went to the code below and covered up the words. is it?

There should be no code after the echo “Hello Sitepoint”;

The idea is to start with a page that works correctly with no errors or warnings then to gradually add code. If any errors or warnings appear then find the cause and fix the errors.

Your script can be seen working here:

http://www.johns-jokes.com/downloads/sp-a/marvin_g/index-001.php

u mean by just executing php code? ofcourse i can execute it. i’ve so many .php files works and there’s nothing wrong about it. the link u gave me is actually not complete because i you don’t have the .css and .js script which called in the code i gave previously so u can’t really see the “data management” button that suppose to link to the .js file. i tried to upload picture here but cannot and i dont know why@.@