Jump to content

IE cannot read the php file


tinfanide

Recommended Posts

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 		"http://www.w3.org/TR/html4/loose.dtd"><htmL><head><title>Homeapge</title></head><body><div id="header"><h1>Home</h1></div><div id="menu"><a href="index.php">Home</a><a href="index.php?p=about">About us</a><a href="index.php?p=contact">Contact us</a><a href="index.php?p=news">News</a><hr /></div><div id="content">	<?php			if (!empty($_GET['p'])) {						$pages_dir = 'pages';						$pages = scandir($pages_dir, 0);						print_r($pages);						$p = $_GET('p');								}		?></div></body></html>

I'm starting learning php and find my index.php file cannot be read by IE. Instead, IE8 just shows me the codes as plain texts but firefox doesn't (firefox shows the proper php page).My index.php file has links to a couple of php files:about.inc.phpcontact.inc.phpnews.inc.phpI've been testing around the !DOCTYPE issue and finally followed the tutorial's one loose.dtd butmy little knowledge of php cannot let me go any further and am thus stuck at this point.Is there any code which turns the IE8 to work with php or anything missing in my codes to make it work in IE8?Thanks.

Link to comment
Share on other sites

Use <?PHPecho 'HTML TAGS HERE';if (!empty($_GET['p'])) {						$pages_dir = 'pages';						$pages = scandir($pages_dir, 0);						print_r($pages);						$p = $_GET('p');								}echo 'SOME OTHER CLOSE TAGS';?>

Link to comment
Share on other sites

Use <?PHPecho 'HTML TAGS HERE';if (!empty($_GET['p'])) {						$pages_dir = 'pages';						$pages = scandir($pages_dir, 0);						print_r($pages);						$p = $_GET('p');								}echo 'SOME OTHER CLOSE TAGS';?>

he doesn't have to do it that way per se. There's nothing wrong with including PHP mid file. PHP doesn't have to echo out all the HTML if you are only trying to use a snippet of PHP.one problem could be this line:
$p = $_GET('p');

it should be brackets, not parens. Have you tried this PHP code just on it's own, with no HTML, as a basic test? Are you sure you are testing this on a machine that's running PHP, and located in the webroot? Is 'pages' a valid directory?

Link to comment
Share on other sites

he doesn't have to do it that way per se. There's nothing wrong with including PHP mid file. PHP doesn't have to echo out all the HTML if you are only trying to use a snippet of PHP.one problem could be this line:
$p = $_GET('p');

it should be brackets, not parens. Have you tried this PHP code just on it's own, with no HTML, as a basic test? Are you sure you are testing this on a machine that's running PHP, and located in the webroot? Is 'pages' a valid directory?

Yes, you've got the point.After getting the first reply, I'd been checking it on the Internet.The first problem was "$_GET['p']. It should be [], not ().The second problem was even some complicated to me. I have tried PHP codes (as simple as just echo "Hello World") but IE does just show the codes as plain text (the screen shows me echo "Hello World". But Firefox does."pages" valid dir.The problem lies in the fact that my machine does not run php (? Not sure) and I found I didn't have a root folder on the server (sorry, at that time I had not known php files had to be put on to the server... I just thought it was the same as HTML or JS).Later on I went for XAMPP but failed (I didn't know why. XAMPP just said to me failed running the aphac) after that I knew that I could not do the php script then as I could not follow what the online tutorial on XAMPP & php taught.Even Firefox ran the php scripts. When I did dynamic pages on php, Firefox did not show other pages dynamically. I thought it was due to the absence of my localhost.After installing XAMPP, I typed in http://localhost/index.php (index.php was the file with the scripts mentioned by me above), it returned error page.So I thought nothing can be done before I worked out how to run the XAMPP aphac. Is the concept right, mates? Please give me some thoughts if you can. Many thanks.
Link to comment
Share on other sites

yes, as described in the intro of the tutshttp://www.w3schools.com/php/php_intro.aspyou need to operate PHP within the context of a server environment; i.e. something that can run PHP files. If you are having problems with XAMPP, have you tried just WAMP? Either way, you need to either test locally in a simulated server environment or the long way is to upload your files to a hosting site that has PHP installed,

Link to comment
Share on other sites

Firefox and IE and any other browser does not understand or run PHP code. Only the server runs PHP code. PHP is a server-side language, the browser doesn't even have permission to do the vast majority of things that PHP is used for. You need to get the server working, then copy your PHP files to your server directory, then access the files over HTTP. You can't just double-click on the file to open it in the browser, you need to type the URL, and the URL needs to start with HTTP.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...