When I run my website I have random bits of php showing, and the background doesn't appear. Here is what bit is showing

"); } ?>

and here is my code

<!DOCTYPE html>

<head> 
	<title>Website Name</title>
	<meta http-equiv="Content-Type" content="text/html; charSet=UTF-8"> 
    <link rel="stylesheet" href="styles.css" media="screen" />
</head>

<body>
	<div class="wrapper">
		<center>
			<div class="header"></div>
			<div class="navbar">
				<div class="button"><a href="index.php">Főoldal</a></div>
				<div class="button"><a href="products.php">Termékek</a></div>
				<div class="button"><a href="about.php">Rólunk</a></div>
				<div class="button"><a href="contact.php">Elérhetőség</a></div>	
			</div>
			<div class="textbody">
			<?php
				if ($_GET['page'] == "fa"){
					echo ("<h1>Fa Áruk</h1><hr /><br />");
				}
			?>
		</div>
		</center>
	</div>
</body>
</html>

also the header tag isn't as large as it should be.

Thanks for any help.

Recommended Answers

All 4 Replies

Member Avatar for diafol

Try:

echo "<h1>Fa Aruk</h1><hr /><br />";

without the accent and parentheses. If it's the accents, it may be a UTF-8 encoding issue.
I can't see any unbalanced quotes.

There's definitely no more php in the page than this?

the accent needs to be there, but even without it it didn't make a difference. here is the output after I inserted your code

"; } ?>

and that is the whole webpage.

when I am using my $_GET I am getting the page from the url right, because the way I made this is on the products page you click something, then it takes you to another page, which has a black middle area, then I will read items from a database and display those. could this be why the error is appearing?

Also it seems to display all of my if statements.

here is my output after adding in another category

Fa Áruk
"; } else if ($_GET['page'] == "villany"){ echo "
Villany Áruk

"; } ?>

and my new code

<!DOCTYPE html>

<head> 
	<title>Website Name</title>
	<meta http-equiv="Content-Type" content="text/html; charSet=UTF-8"> 
    <link rel="stylesheet" href="styles.css" media="screen" />
</head>

<body>
	<div class="wrapper">
		<center>
			<div class="header"></div>
			<div class="navbar">
				<div class="button"><a href="index.php">Főoldal</a></div>
				<div class="button"><a href="products.php">Termékek</a></div>
				<div class="button"><a href="about.php">Rólunk</a></div>
				<div class="button"><a href="contact.php">Elérhetőség</a></div>	
			</div>
			<div class="textbody">
			<?php
				if ($_GET['page'] == "fa"){
					echo "<h1>Fa Áruk</h1><hr /><br />";
				}
				else if ($_GET['page'] == "villany"){
					echo "<h1>Villany Áruk</h1><hr /><br />";
				}
			?>
			
			
			

		</div>
		</center>
	</div>
</body>
</html>
Member Avatar for diafol

Sounds to me that you don't have php installed properly or you've saved the file as *.html

If it's displaying your php code, it suggests that php isn't being processed on the server.

when I uploaded it to my host it worked fine. it must have been something to do with my comp. Thanks for the help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.