include probleem

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Seti Soeparman

Seti Soeparman

13/07/2011 13:51:01
Quote Anchor link
hallo,

ik weet dat hier al veel topics over zijn, maar krijg niet het juiste antwoord ervan..

ik heb een nieuwsscript die ik wil gebruiken in mijn index pagina, als ik hem zo draai doet die het gewoon, maar wanneer ik hem wel includen in me index pagina

Quote:
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
<?
  include("nieuws/index.php");
  ?>


heb ook al ./ en / en ../ geproneerd maar krijg bij alles de errors

Warning: include(www.hemmerworks.nl/nieuws/libs/include.inc.php) [function.include]: failed to open stream: No such file or directory in /mnt/webc/10/71/52673571/htdocs/nieuws/index.php on line 2

Warning: include() [function.include]: Failed opening 'www.hemmerworks.nl/nieuws/libs/include.inc.php' for inclusion (include_path='.:/opt/RZphp5/includes') in /mnt/webc/10/71/52673571/htdocs/nieuws/index.php on line 2

Warning: Cannot modify header information - headers already sent by (output started at /mnt/webc/10/71/52673571/htdocs/index2.php:7) in /mnt/webc/10/71/52673571/htdocs/nieuws/index.php on line 3


Quote:
if(!include('www.hemmerworks.nl/nieuws/libs/include.inc.php')){
header("Location: install.php");
exit;
}
include('../libs/functions.inc.php');
require '../libs/Smarty.class.php';



ook alles geprobeerd zonder site en met ./ / ../

maar krijg elke keer soort gelijke errors..
ik denk dat het probleem is omdat in het nieuwsscript ook de code include wordt gebruikt.. maar hoe moet ik dit aanpassen???

alvast bedankt!
 
PHP hulp

PHP hulp

12/02/2025 19:16:53
 
Wesley PHP

Wesley PHP

13/07/2011 13:54:22
Quote Anchor link
Volgens de 1e error bestaat het bestand niet.
Gewijzigd op 13/07/2011 13:59:36 door Wesley PHP
 
- Ariën  -
Beheerder

- Ariën -

13/07/2011 14:04:29
Quote Anchor link
Dit lijkt me een raar pad:
www.hemmerworks.nl/nieuws/libs/include.inc.php

Wat meldt $_SERVER['DOCUMENT_ROOT'] ?
Gewijzigd op 13/07/2011 14:05:06 door - Ariën -
 
Seti Soeparman

Seti Soeparman

13/07/2011 14:05:34
Quote Anchor link
ja das het rare hij bestaat wel,
ik denk alleen omdat er een dubbele include inzit dat die daarom niet de goeie directory pakt.. maar ik heb alle soorten al gebruikt..

op http://www.hemmerworks.nl/nieuws/index.php doet die het wel
maar op http://www.hemmerworks.nl/index2.php niet..
 
Tobias Tobias

Tobias Tobias

13/07/2011 14:06:25
Quote Anchor link
als je een bestand include die in een andere map staat, moeten eventuele includes/requires die in dat bestand staan aangeroepen worden alsof het bestand in de bronmap staat.

Voorbeeld:
in index.php: include 'nieuws/a.php';
in a.php: include 'x.php';
Dan moet x dus in de hoofdmap zitten, niet in de map nieuws
 
Seti Soeparman

Seti Soeparman

13/07/2011 14:07:10
Quote Anchor link
waar vind ik $_SERVER['DOCUMENT_ROOT'] ?

Toevoeging op 13/07/2011 14:10:00:

dan zou ik dus alle include bestanden van het script naar de bronmap moeten verplaatsen.. of is daar een speciale code voor dat ik ze kan laten staan waar ze nu staan?
 
Wesley PHP

Wesley PHP

13/07/2011 14:12:56
Quote Anchor link
Je moet $_SERVER['DOCUMENT_ROOT'] plaatsen in include.inc.php en dan echo-en.
 
Seti Soeparman

Seti Soeparman

13/07/2011 14:16:47
Quote Anchor link
sorry mijn verstand van php is minimaal waar zou ik $_SERVER['DOCUMENT_ROOT'] moeten plaatsen dan? bovenaan?

en waar en hoe zou ik hem moeten echo'en?
 
Joren de Wit

Joren de Wit

13/07/2011 14:18:01
Quote Anchor link
Nee je hoeft de bestanden van het script niet naar de bronmap te verplaatsen. Wat je wel kunt doen, is de paden naar de bestanden die geïnclude moeten worden, vanaf de document root specificeren.

Dat is precies waar $_SERVER['DOCUMENT_ROOT'] handig voor is, aangezien die variabele het absolute pad naar je document root geeft. Vanaf daar kun je dus verder gaan bouwen. Bijvoorbeeld:

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
<?php
$pad
= $_SERVER['DOCUMENT_ROOT'].'nieuws/include.php';
?>

Controleer eerst even wat de inhoud van die $_SERVER variabele is (door hem ergens te echoën) en kijk dan vooral of hij al eindigt met een /.
 
Tobias Tobias

Tobias Tobias

13/07/2011 14:18:12
Quote Anchor link
Seti Soeparman op 13/07/2011 14:07:10:
dan zou ik dus alle include bestanden van het script naar de bronmap moeten verplaatsen.. of is daar een speciale code voor dat ik ze kan laten staan waar ze nu staan?


Je zou er een absolute link van kunnen maken (dus met http: etc ervoor)

EDIT: Joren was me voor met een beter alternatief
Gewijzigd op 13/07/2011 14:18:53 door Tobias Tobias
 
Seti Soeparman

Seti Soeparman

13/07/2011 14:19:42
Quote Anchor link
en zou ik dat dan bij alle bestanden moeten doen die ge-include worden?

Warning: Smarty error: unable to read resource: "header.tpl" in /mnt/webc/10/71/52673571/htdocs/nieuws/libs/Smarty.class.php on line 1088

Warning: Smarty error: unable to read resource: "home.tpl" in /mnt/webc/10/71/52673571/htdocs/nieuws/libs/Smarty.class.php on line 1088

Warning: Smarty error: unable to read resource: "footer.tpl" in /mnt/webc/10/71/52673571/htdocs/nieuws/libs/Smarty.class.php on line 1088

dit krijg ik nu ook, ik had dit veranderd, dat helpt al wel iets volgensmij..
Quote:
if(!include('nieuws/libs/include.inc.php')){
header("Location: install.php");
exit;
}
include('nieuws/libs/functions.inc.php');
require 'nieuws/libs/Smarty.class.php';

 
- SanThe -

- SanThe -

13/07/2011 14:20:57
Quote Anchor link
http://www.phphulp.nl/php/tutorial/php-functies/de-functie-include/286/korte-uitleg-met-voorbeeldje/540/

Toevoeging op 13/07/2011 14:23:14:

Deze doet het altijd:
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
<?php
include (str_repeat('../', substr_count(substr(__FILE__, strlen($_SERVER['DOCUMENT_ROOT'])+1), '/')) . 'map_vanuit_de_root/bestand.php');
?>
 
Seti Soeparman

Seti Soeparman

13/07/2011 14:46:17
Quote Anchor link
ik heb je code ingevoerd santhe en ik heb ze allemaal geprobeerd, hoe je ook had beschreven, ik snap het principe wel maar op 1 of andere manier blijf ik foutmeldingen krijgen. hij blijft errors geven op line 2 mja daar heb ik elke variatie geprobeerd..

mischien ligt het probleem ergens anders?
Quote:
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
if(!include('../nieuws/libs/include.inc.php')){
    header("Location: install.php");
    exit;
}

include('libs/functions.inc.php');
require 'libs/Smarty.class.php';

function
checkmail($string){
    return preg_match("/^[^\s()<>@,;:\"\/\[\]?=]+@\w[\w-]*(\.\w[\w-]*)*\.[a-z]{2,}$/i",$string);
}


if(isset($_GET['template']))
$_SESSION['template']=$_GET['template'];
elseif(!isset($_SESSION['template']))$_SESSION['template']=$__template;


$smarty = new Smarty;
$smarty->template_dir="templates/".$__template;
//$smarty->compile_check = true;
//$smarty->debugging = true;

$smarty->assign("Title","MyNews V1.5");
$smarty->assign("_SERVER",$_SERVER);
$smarty->assign("template",$_SESSION['template']);

$smarty->display('header.tpl');

if(!isset($_GET['Archive'])){
    $Sql="SELECT * FROM ".$SqlPrefix."news ORDER BY id DESC LIMIT ".$MaxPage;
    if($Result = mysql_query($Sql)){
        while($Row = mysql_fetch_assoc($Result)){
            $Sql1="SELECT COUNT(1) FROM ".$SqlPrefix."comments WHERE news_id='".$Row['id']."'";
            if($Result1 = mysql_query($Sql1)){
                $Re = mysql_result($Result1,0);
            }
else{
                $Re = 'Select error';
            }

            $mss[]=array('id'=>$Row['id'],
            'title'=>stripslashes(htmlspecialchars($Row['title'])),
            'message'=>Message($Row['message']),
            '_time'=>datum_tijd($Row['_time']),
            're'=>$Re);
        }

        $smarty->assign("mss", $mss);
    }
else{
        $error['error']=mysql_error();
        $error['sql']=$Sql;
        $smarty->assign("error",$error);
    }

    $smarty->display('home.tpl');
}
elseif($_GET['Archive'] == '0'){
    $Sql = "SELECT id,title,_time FROM ".$SqlPrefix."news ORDER BY _time DESC";
    if($Result = mysql_query($Sql)){
        while($Row = mysql_fetch_assoc($Result)){
            $Sql1="SELECT COUNT(1) FROM ".$SqlPrefix."comments WHERE news_id='".$Row['id']."'";
            if($Result1 = mysql_query($Sql1)){
                $Re=mysql_result($Result1,0);
            }
else{
                $error['error']=mysql_error();
                $error['sql']=$Sql1;
                $smarty->assign("error",$error);
            }

            $archief[]=array('id'=>$Row['id'],
            'title'=>stripslashes(htmlspecialchars($Row['title'])),
            '_time'=>datum($Row['_time']),
            're'=>$Re);
            $smarty->assign("archief",$archief);
        }
    }

    $smarty->display('archive.tpl');
}
else{
    $Sql="SELECT * FROM ".$SqlPrefix."news WHERE id='".$_GET['Archive']."'";
    if($Result = mysql_query($Sql)){
        $Row = mysql_fetch_assoc($Result);
        
        $news=array('id'=>$Row['id'],
        'title'=>stripslashes(htmlspecialchars($Row['title'])),
        'message'=>Message($Row['message']),
        '_time'=>datum_tijd($Row['_time']));
        
        $smarty->assign("news",$news);
    }
else{
        $error['error']=mysql_error();
        $error['sql']=$Sql;
        $smarty->assign("error",$error);
    }

    if($_SERVER['REQUEST_METHOD'] == 'POST'){
        if(!empty($_POST['name'])){
            if(!empty($_POST['message'])){
                if(!empty($_POST['email']) && checkmail($_POST['email'])){
                    mysql_query("INSERT INTO ".$SqlPrefix."comments (message,name,email,ip,news_id,datum) VALUES ('".$_POST['message']."','".$_POST['name']."','".$_POST['email']."','".$_SERVER['REMOTE_ADDR']."','".$_GET['Archive']."',NOW())")or die(mysql_error());
                }
            }
        }
    }

    $Sql = "SELECT * FROM ".$SqlPrefix."comments WHERE news_id='".$_GET['Archive']."' ORDER BY id DESC";
    if($Result = mysql_query($Sql)){
        if(mysql_num_rows($Result) > 0){
            while($Row = mysql_fetch_assoc($Result)){
                $re[]=array('name'=>htmlspecialchars($Row['name']),
                'email'=>htmlspecialchars($Row['email']),
                'message'=>Reply($Row['message']),
                'datum'=>datum_tijd($Row['datum']));
            }

            $smarty->assign("re",$re);
        }
    }
else{
        $error['error']=mysql_error();
        $error['sql']=$Sql;
        $smarty->assign("error",$error);
    }

    $smarty->display('article.tpl');
}




$smarty->display('footer.tpl');
?>
 
Wesley PHP

Wesley PHP

13/07/2011 14:52:32
Quote Anchor link
Welk bestand is dit en waar staat het? In welke map of iets dergelijke.

EDIT: Verkeerd gekeken.
Gewijzigd op 13/07/2011 15:08:01 door Wesley PHP
 
Seti Soeparman

Seti Soeparman

13/07/2011 15:04:55
Quote Anchor link
dit is index.php van nieuws/index.php in de dir van nieuws in deze dir staan alle andere dirs waarna word geinclude wordt vanaf deze pagina..

daarnaast heb ik nu de index2.php en hier staat op dit moment de code

Quote:
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
<?php
include (str_repeat('../', substr_count(substr(__FILE__, strlen($_SERVER['DOCUMENT_ROOT'])+1), '/')) . 'nieuws/index.php');
?>


EDIT: is het mischien makkelijker om gewoon een iframe te gebruiken?

Toevoeging op 13/07/2011 15:43:39:

Heejj het is gelukt! ik moest de dir in wat andere bestanden veranderen :)

bedankt voor de ideeen iig!
Gewijzigd op 13/07/2011 15:12:33 door Seti Soeparman
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.