Jump to content

include doesnt work


moffo

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/113136-include-doesnt-work/
Share on other sites

comments like that aint gonna get you help of anyone...

 

Post the code in the code tags like already mentioned

 

Your question makes little sense. Which include call are you talking about?

 

And please, use


tags when posting code.

 

and be more specific what error messages are you getting etc

Link to comment
https://forums.phpfreaks.com/topic/113136-include-doesnt-work/#findComment-581457
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.