Reputation: 2737
I have a form with a textarea control, mainly to input an article that consists of pure text... Inside the textarea control, i have text like
I submit the form and save the textarea data into a database field. So far so good..
When in a browser, i'm trying to output the database field, but i dont get the content of the php include file, instead i get something like the following:
The php tags are commented!!!
Why is the browser not showing/parsing the content of the include file?
UPDATED: this is the content of test.php
<?php
echo test;
?>
this is the code of article.php
<?php
require_once('../includes/global.inc.php');
require_once('../includes/connection.inc.php');
if (isset($_GET['article']) && is_numeric($_GET['article'])) {
$get_article = (int)$_GET['article'];
$conn = connect('read');
$sql = 'SELECT article.article_id, article.title, article.description, article.article, article.seo_url
FROM article
WHERE article.article_id = ?';
$stmt = $conn->stmt_init();
$stmt->prepare($sql);
$stmt->bind_param('i', $get_article);
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($articleid, $title, $description, $article, $seourl);
$stmt->fetch();
$stmt->free_result();
$stmt->close();
}
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
...
</head>
<body>
<?php
echo $title;
echo $article;
?>
</body>
</html>
Upvotes: 0
Views: 299
Reputation: 157947
Seems like you misunderstood where PHP is executed. PHP is executed on the server and not in the browser. You'll have to make sure the site will be parsed on server by PHP. You'lll mostly do it by using a PHP enabled webserver and giving the file a .php extension.
The php code isn't outcommented. Thats just your debugging tool that shows it outcommented because the opening <?php
would lead to invalid HTML. It could also be possible that HTML parser of your browser adds the <!--
to avoid problems with the opening php. I don't know this exactly.
You can verify this by viewing the raw html source code and you'll see there is no magic that comments out your php :)
Upvotes: 2