PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, January 2, 2022

[FIXED] Testing PHP files locally

 January 02, 2022     localhost, mamp, php, testing     No comments   

Issue

I created 2 php files (index.php and header.php). I am trying to test the "include" parameter for headers. I want to test the files locally on my Mac. I cant seem to get it to work.

I downloaded and installed MAMP and everything seems to be working fine. I pointed the document root to the correct folder. When I go to the //localhost:8888 I get a server error message.

What am I doing wrong? Do I need to configure something or do something with the mysql database? Any help would be great.

Thanks.

edit

PHP files:

header.php:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>header</title>
</head>
<body>

<h1> My Logo </h1>

<ul>
    <li> <a href=""> home </a> </li>
    <li> <a href=""> about </a> </li>
    <li> <a href=""> portfolio </a> </li>
    <li> <a href=""> contact </a> </li>
</ul>

</body>
</html>

index.php:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>header</title>
</head>
 <body>
<?php include("header.php"); ?>

<h2> blah blah blah </h2>

<p>
    dfgwgwergfwrgrgrjgjkfjkwfjwkfnkjnfwekjnfkjewnfknfwef <br />
    dkkngkjernjkeer er gk erjg jrek gjkerjkeg jker gerj ge <br />
    dfjdgnreg ergjer gjkerg erg er gjerjg kjer gjker gkerj gerk <br />
</p>

</body>
</html>

Server Error Message:

"The website encountered an error while retrieving "http://localhost:8888/". It may be down for maintenance or configured incorrectly.

Here are some suggestions: Reload this webpage later.

HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.


Solution

Remove your XML tags in the first line of both files

Also, use only the essencial in the header.php. It isn0t needed but makes better code. Like this:

<h1> My Logo </h1>

<ul>
    <li> <a href=""> home </a> </li>
    <li> <a href=""> about </a> </li>
    <li> <a href=""> portfolio </a> </li>
    <li> <a href=""> contact </a> </li>
</ul>


Answered By - João Luís
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing