hello,
i have some bad problems in the script. please have a look
articles.php:
<?php
include 'settings.php';
function loadContent($articleNumber){
global $a;
$contentName=$a[$articleNumber].".php";
$f=@file_get_contents("./articles/".$contentName);
if($f)echo $f; else echo "Loading failed";
}
?>
articles_mysql.php:
<?php
function loadContent($articleNumber){
$conn = mysql_connect("localhost", "root", "Vulkan");
mysql_select_db("labs",$conn);
$sql="select * from articles where id='".$articleNumber."'";
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);
$articleName=$row['articleName'].".php";
mysql_close($conn);
$f=@file_get_contents("./articles/".$articleName);
if($f)echo $f; else echo "Loading failed";
}
?>
index.php:
<?php include "articles.php"; ?>
<!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">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Loading contents</title>
</head>
<body>
Here we will load an article that get its contents depending on the ID we send using GET method through the URL string<br>
so add an ID in the URL like localhost/contents/?ID=2<br>
or localhost/contents/index.php?ID=2<br>
<div style="border:1px red dashed;width:400px;height=200;overflow:auto;padding:3px">
<?php
loadContent($_GET['ID']);
?>
</div>
<p>Here we will load a specific article not related to what user sends through the URL, but using known article number</p>
<?php
loadContent(1);
?>
</body>
</html>
settings.php:
<?php
$a=array(
"article0",
"article1",
"article2",
"article3",
"article4",
"article5",
"article6",
"article7",
"article8"
);
?>
and here we open a folder called articles and in this folder we upload article1.php
: <?php include("anything-you-want.php"); ?>
the include doesnt work, why? can someone help me to make this done?
thanks