Romeo
Romeo

Reputation: 25

How to fix this PHP error that prints the code instead of the result?

It should print the error message, but instead it prints:

"data['clan_id'] != 0){echo "You already have a clan.";} ?>"

here is an image of the error: https://i.sstatic.net/uC4Jx.png

my code:

<html>
<style>
.createclanbutton {
background-color: green;
color: black;
padding: 3px;
border-radius: 9px;
}
</style>

<body>

<?php
if ($user->data['clan_id'] != 0)
{
echo "You already have a clan.";
}
?>
<br><br>
<form action="">

<h3>Create your own clan.<br><br>

Clan Name: <input type="text" name="ClanName" value="Clan Name"><br><br>

Description:<br> <textarea rows="6" cols="50">Brief description of your clan!
</textarea><br>
<button class="createclanbutton">Create your own clan!</button>
</form>

</body>
</html>

I am using phpbb and created a column called "clan_id" in my database which I set at "2" to try and echo the error message.

Upvotes: 0

Views: 41

Answers (1)

Toxi
Toxi

Reputation: 109

Looks like you have saved the file as .html or anything? :) You need to save this file as .php!

Upvotes: 1

Related Questions