include probleem
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:
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';
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!
Gewijzigd op 13/07/2011 13:59:36 door Wesley PHP
www.hemmerworks.nl/nieuws/libs/include.inc.php
Wat meldt $_SERVER['DOCUMENT_ROOT'] ?
Gewijzigd op 13/07/2011 14:05:06 door - Ariën -
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..
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
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?
Je moet $_SERVER['DOCUMENT_ROOT'] plaatsen in include.inc.php en dan echo-en.
en waar en hoe zou ik hem moeten echo'en?
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:
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 /.
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?
EDIT: Joren was me voor met een beter alternatief
Gewijzigd op 13/07/2011 14:18:53 door Tobias Tobias
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';
header("Location: install.php");
exit;
}
include('nieuws/libs/functions.inc.php');
require 'nieuws/libs/Smarty.class.php';
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:
Toevoeging op 13/07/2011 14:23:14:
Deze doet het altijd:
Code (php)
1
2
3
2
3
<?php
include (str_repeat('../', substr_count(substr(__FILE__, strlen($_SERVER['DOCUMENT_ROOT'])+1), '/')) . 'map_vanuit_de_root/bestand.php');
?>
include (str_repeat('../', substr_count(substr(__FILE__, strlen($_SERVER['DOCUMENT_ROOT'])+1), '/')) . 'map_vanuit_de_root/bestand.php');
?>
mischien ligt het probleem ergens anders?
Quote:
Code (php)
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
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');
?>
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');
?>
daarnaast heb ik nu de index2.php en hier staat op dit moment de code
Quote:
Code (php)
1
2
3
2
3
<?php
include (str_repeat('../', substr_count(substr(__FILE__, strlen($_SERVER['DOCUMENT_ROOT'])+1), '/')) . 'nieuws/index.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