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
Share on other sites

 

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?

 

 

 

also why dont you try the script i gave above ?

Link to comment
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.