Pb d'Include (je pense)
Posté : 13 mai 2007, 15:33
Bonjour
Je vais essayer d'être clair.
J'ai un site www.site.com (c'est un exemple)
avec dedans index.php head.php et foot.php
dans head.php j'ai :
et dans Index.php j'ai :
Donc, dans Head.php j'ai au niveau de Entête :
Voici aussi le code du ticker.php mes news :
www.site.com/index.php
www.site.com/head.php
www.site.com/foot.php
www.site.com/ticker.php
www.site.com/news.txt (avec 777 comme droit pour l'écriture)
Pour l'instant tout fonctionne bien, sauf que....
J'ai d'autres pages dans différents dossiers :
www.site.com/moto/moto.php
et dans moto.php, je point sur
j'ai un message du genre :
Warning : file (news.txt) : failled to open stream : No such file directory in .....
Je ne sais plus quoi faire
Merci de m'aider
Je vais essayer d'être clair.
J'ai un site www.site.com (c'est un exemple)
avec dedans index.php head.php et foot.php
dans head.php j'ai :
<!DOCTYPE HTML SYSTEM>
<html>
<!-- Date de création : 18 août 2004 -->
<!-- Date de dernière modification (approximatif) : 15 juin 2005 -->
<head>
<title>TOTO.COM</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="date-creation-yyyymmdd" content="20040818">
<meta name="robots" content="index,follow,all">
<meta http-equiv="content-style-type" content="text/css">
<link rel="STYLESHEET" type="text/css" href="/style.css">
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#333333" vlink="#666666" alink="#666666" rightmargin="0" topmargin="0" bottommargin="0" leftmargin="0" onResize="window.location=window.location;">
<!-- ------------------------------------ -->
<!-- Entête -->
<!-- ------------------------------------ -->
<tr valign="top">
<td height="150">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="75%">
<a href="/"><img src="entete01.jpg" border="0" alt="Accueil" height="150"><img src="entete02.jpg" border="0" alt="Accueil" height="150"><img src="entete03.jpg" border="0" alt="Accueil" height="150"><img src="entete04.jpg" border="0" alt="Accueil" height="150"></a>
</td>
<td width="25%" align="right">
<table width="180" height="150" align="right" bgcolor="#3860c0" valign="top">
<?php include "ticker.php"; ?>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<!-- ------------------------------------ -->
<!-- Menu -->
<!-- ------------------------------------ -->
<td height="20">
<script language=JavaScript>
if(document.getElementById)
document.write('<DIV class=popper id=topdeck></DIV>');
</script>
<script language="JavaScript" src="/menu.js">
</script>
<!--<a href="/index.php"><img src="/drapeau_fr.gif" border="0" alt="Accueil" Style="Position:Absolute;Left:50px;Top:155px;z-index:999"></a> <a href="/index.php"><img src="/drapeau_en.gif" border="0" alt="Home" Style="Position:Absolute;Left:70px;Top:155px;z-index:999"></a>-->
</td>
</tr>
<tr valign="top">
<td height="15">
<table width="100%">
<tr>
<td align="right" height="15">
<table width="308" cellspacing="0" border="0"><tr><td bgcolor="#009642" height="3"></td></tr></table>
<table width="306" cellspacing="0" border="0"><tr><td bgcolor="#009642" height="3"></td></tr></table>
<table width="304" cellspacing="0" border="0"><tr><td bgcolor="#009642" height="3"></td></tr></table>
<table width="302" cellspacing="0" border="0"><tr><td bgcolor="#009642" height="3"></td></tr></table>
<table width="300" cellspacing="0" border="0"><tr><td bgcolor="#009642" height="3"></td></tr></table>
</td>
</tr>
</TABLE>
<tr>
<td valign="top">
<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="190" align="center" valign="top">
<!-- ------------------------------------ -->
<!-- Colonne de Gauche -->
<!-- ------------------------------------ -->
<table width="160" border="0" cellspacing="0" cellpadding="0" bgcolor="#3860c0">
<tr>
<td bgcolor="#FFFFFF" height="15">
</td>
</tr>
<tr>
<td>
<table width="100%" valign="center">
<tr>
<td id="Titre" height="20">
Calendrier
</td>
</tr>
<tr>
<td id="Texte" height="100">
<?php include 'calendrier_petit.php'; ?>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td bgcolor="#FFFFFF" height="15">
</td>
</tr>
<tr>
<td>
<table width="100%" valign="center">
<tr>
<td id="Titre" height="20">
Météo
</td>
</tr>
<tr>
<td id="Texte" height="100">
<div style="font-size: 1pt;">
<a href="http://www.meteofrance.com" target="_blank"><img src="/meteofrance.gif" alt="MétéoFrance" border="0"></a><br><br>
<a href="http://oiswww.eumetsat.org/IDDS-cgi/listImages?a=0,m=8,f=1,c=9,o=0,s=2,n=6,d=1,v=400,p=0" target="_blank"><img src="/eumetsat.gif" alt="Eumetsat" border="0"></a><br><br>
<a href="http://www.infoclimat.fr/" target="_blank"><img src="/infoclimat.jpg" alt="Infoclimat" border="0"></a><br><br>
<a href="http://www.montgolfiere.com/meteo.php" target="_parent"><img src="/meteo.jpg" alt="Météo" border="0"></a>
</div>
<!--<table width="100%" border="0" cellpadding="1" cellspacing="0">
<tr>
<td id="Texte">
<img src="http://perso0.free.fr/cgi-bin/meteo.pl?dep=02" alt="Météo de l'Aisne"><br>
Aisne
</td>
<td id="Texte">
<img src="http://perso0.free.fr/cgi-bin/meteo.pl?dep=60" alt="Météo de l'Oise"><br>
Oise
</td>
</tr>
<tr>
<td id="Texte">
<img src="http://perso0.free.fr/cgi-bin/meteo.pl?dep=80" alt="Météo de la Somme"><br>
Somme
</td>
<td id="Texte">
<img src="http://perso0.free.fr/cgi-bin/meteo.pl?dep=75" alt="Météo de Paris"><br>
Paris-->
<!-- </td>
</tr>
</table>-->
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td bgcolor="#FFFFFF" height="15">
</td>
</tr>
<tr>
<td>
<table width="100%" valign="center">
<tr>
<td id="Titre" height="20">
Itinéraire
</td>
</tr>
<tr>
<td id="Texte" height="40">
<a href="http://www.viamichelin.com/" target="_blank" alt="ViaMichelin"><img src="/viamichelin.jpg" border="0" width="160"></a>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td bgcolor="#FFFFFF" height="15">
</td>
</tr>
<tr>
<td>
<table width="100%" valign="center">
<tr>
<td id="Titre" height="20">
Partenaires
</td>
</tr>
<tr>
<td id="Texte" height="40">
<?php
if ((isset($_SESSION['login']))&&(!empty($_SESSION['login']))&&(!empty($_SESSION['nom']))){
echo "<form action=\"/fin_session.php\" method=\"post\">";
echo " <input type=\"hidden\" name=\"page\" value=\"".$_SERVER['REQUEST_URI']."\">";
echo " Connexion : ".$_SESSION['nom']."<BR>";
echo "<a href=\"/admin/moncompte.php\">Gestion de mon compte</a><BR>";
if ($_SESSION['niveau']=="admin") {
echo "<a href=\"/admin/comptes.php\">Gestion des comptes</a><BR>";
echo "<a href=\"/admin/carte.php\">Gestion de la carte</a><BR>";
echo "<a href=\"/admin/calendrier.php\">Gestion de l'agenda</a><BR>";
}
echo " <input type=\"submit\" value=\"Déconnexion\" id=\"Texte\">";
} else {
echo "<form action=\"".$_SERVER['REQUEST_URI']."\" method=\"post\">";
?>
<table width="100%">
<tr>
<td id="Texte" style="Text-Align: left;">
Login :
</td>
<td id="Texte" style="Text-Align: right;">
<input type="text" name="login" size="10">
</td>
</tr>
</table>
<table width="100%">
<tr>
<td id="Texte" style="Text-Align: left;">
Password :
</td>
<td id="Texte" style="Text-Align: right;">
<input type="password" name="password" size="7">
</td>
</tr>
</table>
<input type="submit" value="Connexion" id="Texte">
<?php
}
?>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</td>
<td valign="center">
Ensuite dans Foot.php juste du texte commun a toute les pageset dans Index.php j'ai :
<?php include 'head.php'; ?>
<!-- Contenu -->
<center>
<div id="TitrePage">INDEX TOTO.COM<sup>®</sup></div>
<!--<map name="Michelin">
<area shape="rect" coords="150,250,200,270" href="http://www.viamichelin.com/b2b2c/fra/dyn/controller/dlPoiAccess?id=PIBAL01&productId=66490">
</map>-->
<?php
$request="SELECT * FROM `ballon_actif_carte` WHERE 1";
$result=mysql_query($request);
$actif=mysql_result($result,0,'actif');
?>
<table width=486>
<tr>
<td id="Carte" height="398">
<div style='position: absolute'><!-- Baie de Somme --><a href="carte/valery.php" target="_blank"><img name='ville1' src="ballon.gif" onMouseOver="this.src='ballon_over.gif';" onMouseOut="this.src='ballon<? echo ($actif==1?'_anim':''); ?>.gif';" style="position: relative; top: 40px; left: 40px;" border=0></a></div>
<div style='position: absolute'><!-- Abbeville - Flixecourt --><img name='ville2' src="ballon.gif" onMouseOver="this.src='ballon_over.gif';" onMouseOut="this.src='ballon<? echo ($actif==2?'_anim':''); ?>.gif';" style="position: relative; top: 70px; left: 72px;" border=0></div>
<div style='position: absolute'><!-- Saint-Germer-de-Fly --><a href="carte/germer.php" target="_blank"><img name='ville3' src="ballon.gif" onMouseOver="this.src='ballon_over.gif';" onMouseOut="this.src='ballon<? echo ($actif==3?'_anim':''); ?>.gif';" style="position: relative; top: 240px; left: 72px;" border=0></a></div>
<div style='position: absolute'><!-- Poix-de-Picardie --><img name='ville4' src="ballon.gif" onMouseOver="this.src='ballon_over.gif';" onMouseOut="this.src='ballon<? echo ($actif==4?'_anim':''); ?>.gif';" style="position: relative; top: 130px; left: 94px;" border=0></div>
<div style='position: absolute'><!-- Samara --><a href="carte/samara.php" target="_blank"><img name='ville5' src="ballon.gif" onMouseOver="this.src='ballon_over.gif';" onMouseOut="this.src='ballon<? echo ($actif==5?'_anim':''); ?>.gif';" style="position: relative; top: 100px; left: 120px;" border=0></a></div>
<div style='position: absolute'><!-- Amiens --><a href="carte/dury.php" target="_blank"><img name='ville6' src="ballon.gif" onMouseOver="this.src='ballon_over.gif';" onMouseOut="this.src='ballon<? echo ($actif==6?'_anim':''); ?>.gif';" style="position: relative; top: 120px; left: 160px;" border=0></a></div>
<div style='position: absolute'><!-- Montdidier --><a href="carte/montdidier.php" target="_blank"><img name='ville7' src="ballon.gif" onMouseOver="this.src='ballon_over.gif';" onMouseOut="this.src='ballon<? echo ($actif==7?'_anim':''); ?>.gif';" style="position: relative; top: 168px; left: 166px;" border=0></a></div>
<div style='position: absolute'><!-- Chantilly --><img name='ville8' src="ballon.gif" onMouseOver="this.src='ballon_over.gif';" onMouseOut="this.src='ballon<? echo ($actif==8?'_anim':''); ?>.gif';" style="position: relative; top: 272px; left: 166px;" border=0></div>
<div style='position: absolute'><!-- Ansacq --><a href="carte/ansacq.php" target="_blank"><img name='ville9' src="ballon.gif" onMouseOver="this.src='ballon_over.gif';" onMouseOut="this.src='ballon<? echo ($actif==9?'_anim':''); ?>.gif';" style="position: relative; top: 248px; left: 194px;" border=0 ></a></div>
<div style='position: absolute'><!-- Amiens - Péronne --><img name='ville10' src="ballon.gif" onMouseOver="this.src='ballon_over.gif';" onMouseOut="this.src='ballon<? echo ($actif==10?'_anim':''); ?>.gif';" style="position: relative; top: 110px; left: 204px;" border=0></div>
<div style='position: absolute'><!-- Compiègne --><img name='ville11' src="ballon.gif" onMouseOver="this.src='ballon_over.gif';" onMouseOut="this.src='ballon<? echo ($actif==11?'_anim':''); ?>.gif';" style="position: relative; top: 214px; left: 220px;" border=0></div>
<div style='position: absolute'><!-- Péronne --><img name='ville12' src="ballon.gif" onMouseOver="this.src='ballon_over.gif';" onMouseOut="this.src='ballon<? echo ($actif==12?'_anim':''); ?>.gif';" style="position: relative; top: 114px; left: 258px;" border=0></div>
<div style='position: absolute'><!-- Pierrefonds --><a href="carte/pierrefonds.php" target="_blank"><img name='ville13' src="ballon.gif" onMouseOver="this.src='ballon_over.gif';" onMouseOut="this.src='ballon<? echo ($actif==13?'_anim':''); ?>.gif';" style="position: relative; top: 264px; left: 248px;" border=0></a></div>
<div style='position: absolute'><!-- Villers-Cotterêts Soissons --><a href="carte/saconin.php" target="_blank"><img name='ville14' src="ballon.gif" onMouseOver="this.src='ballon_over.gif';" onMouseOut="this.src='ballon<? echo ($actif==14?'_anim':''); ?>.gif';" style="position: relative; top: 254px; left: 306px;" border=0></a></div>
<div style='position: absolute'><!-- Saint-Quentin --><img name='ville15' src="ballon.gif" onMouseOver="this.src='ballon_over.gif';" onMouseOut="this.src='ballon<? echo ($actif==15?'_anim':''); ?>.gif';" style="position: relative; top: 134px; left: 328px;" border=0></div>
<div style='position: absolute'><!-- Château-Thierry --><img name='ville16' src="ballon.gif" onMouseOver="this.src='ballon_over.gif';" onMouseOut="this.src='ballon<? echo ($actif==16?'_anim':''); ?>.gif';" style="position: relative; top: 344px; left: 340px;" border=0></div>
<div style='position: absolute'><!-- Laon Nord --><img name='ville17' src="ballon.gif" onMouseOver="this.src='ballon_over.gif';" onMouseOut="this.src='ballon<? echo ($actif==17?'_anim':''); ?>.gif';" style="position: relative; top: 180px; left: 360px;" border=0></div>
<div style='position: absolute'><!-- Laon Sud --><img name='ville18' src="ballon.gif" onMouseOver="this.src='ballon_over.gif';" onMouseOut="this.src='ballon<? echo ($actif==18?'_anim':''); ?>.gif';" style="position: relative; top: 210px; left: 378px;" border=0></div>
<div style='position: absolute'><!-- Hirson --><img name='ville19' src="ballon.gif" onMouseOver="this.src='ballon_over.gif';" onMouseOut="this.src='ballon<? echo ($actif==19?'_anim':''); ?>.gif';" style="position: relative; top: 96px; left: 418px;" border=0></div>
<!--<img src="carte.gif" border="0" alt="La Picardie" usemap="#Michelin" style="position: relative; top: 0px; left: 00px;">-->
</td>
</tr>
</table>
<?php
if ($actif!=0) {
?>
<script language='javascript'>
test='ville<? echo $actif; ?>';
a=document.getElementById(test);
a.src='../ballon_anim.gif';
</script>
<?
}
?>
<br>
<!--<TABLE WIDTH=470>
<TR>
<TD>-->
<DIV ID="TexteIntroPage">
TOTO.COM<sup>®</sup>
</DIV>
<DIV ID="TexteIntroPageSmall">
01010101 ou<br>
<img src="telephone.gif" alt="02020202"><br>
<!-- Adresse e-mail cryptée contre le spam -->
<script type="text/javascript" language="javascript"><!--
eval(unescape(
'%76%61%72%20%65%3D%27%63%6F%6E%74%61%63%74%27%2B%27%40'+
'%27%2B%27%6D%6F%6E%74%67%6F%6C%66%69%65%72%65%2E%63%6F'+
'%6D%27%3B%64%6F%63%75%6D%65%6E%74%2E%77%72%69%74%65%28'+
'%27%3C%61%20%68%72%65%66%3D%22%6D%61%69%6C%74%6F%3A%27'+
'%2B%65%2B%27%22%20%74%69%74%6C%65%3D%22%27%2B%65%2B%27'+
'%22%3E%27%2B%65%2B%27%3C%2F%61%3E%27%29'));
// -->
</script><br>
<br>
<br>
Bla Bla Bla Bla<br>
</DIV>
<br>
<DIV ID="TexteIntroPageSmall">
Bla BloBloBlo Cla<br>
</DIV>
<br>
<DIV ID="TexteIntroPage">
Titi<sup>®</sup> !
</DIV>
<!-- </TD>
</TR>
</TABLE>-->
</center>
<?php include 'foot.php'; ?>
Voilà, sauf que j'ai trouver un Lecteur de news en php, a partir d'un fichier .txt.Donc, dans Head.php j'ai au niveau de Entête :
<!-- ------------------------------------ -->
<!-- Entête -->
<!-- ------------------------------------ -->
<tr valign="top">
<td height="150">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="75%">
<a href="/"><img src="entete01.jpg" border="0" alt="Accueil" height="150"><img src="entete02.jpg" border="0" alt="Accueil" height="150"><img src="entete03.jpg" border="0" alt="Accueil" height="150"><img src="entete04.jpg" border="0" alt="Accueil" height="150"></a>
</td>
<td width="25%" align="right">
<table width="180" height="150" align="right" bgcolor="#3860c0" valign="top">
<?php include "ticker.php"; ?>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
Ce qui a pour but, de m'afficher correctement mes news.Voici aussi le code du ticker.php mes news :
<html><head>
<style type="text/css">
<!--
.Style1 {
color: #FFFFFF;
font-weight: normal;
}
-->
</style>
</head><body>
<?php
$password = "test"; //CHANGE THE LOGIN PASSWORD
extract($HTTP_GET_VARS);
extract($HTTP_POST_VARS);
if ($action != "admin" && $action != "login" && $action!= "temp3"){
?>
<TABLE width="180" height="140" cellPadding=0 cellSpacing=0 bordercolor="#3860c0" bgcolor=#CCCCCC style="BORDER-RIGHT: #3860c0 0px double; PADDING-RIGHT: 0px; BORDER-TOP: #3860c0 0px double; PADDING-LEFT: 0px; FONT-WEIGHT: bold; FONT-SIZE: 10px; BACKGROUND-IMAGE: PADDING-BOTTOM: 0px; MARGIN: 0px; VERTICAL-ALIGN: top; BORDER-LEFT: #3860c0 0px double; WIDTH: 180px; COLOR: #ffffff; PADDING-TOP: 0px; BORDER-BOTTOM: #3860c0 0px double; FONT-STYLE: normal; FONT-FAMILY: Arial, Helvetica, sans-serif; TEXT-DECORATION: none" >
<TBODY>
<TR bgcolor="#3860c0">
<TD width="180" style="BORDER-RIGHT: #3860c0 0px double; PADDING-RIGHT: 0px; BORDER-TOP: #3860c0 0px double; PADDING-LEFT: 0px; FONT-WEIGHT: bold; FONT-SIZE: 20px; MARGIN: 0px; VERTICAL-ALIGN: center; BORDER-LEFT: #3860c0 0px double; COLOR: #ffffff; LINE-HEIGHT: normal; PADDING-TOP: 0px; BORDER-BOTTOM: #3860c0 0px double; BACKGROUND-REPEAT: repeat-x; FONT-STYLE: normal; FONT-FAMILY: Arial, Helvetica, sans-serif; HEIGHT: 20px; TEXT-DECORATION: none; FONT-SIZE: 10px; COLOR: #000000; FONT-FAMILY: Verdana, Helvetica, Arial "><div align="center"><span class="Style1"> <b>News</b></span></div></TD>
</TR>
<TR>
<TD height="120" style="BORDER-RIGHT: #3860c0 2px double; PADDING-RIGHT: 4px; BACKGROUND-POSITION: center bottom; BORDER-TOP: #3860c0 2px double; PADDING-LEFT: 4px; FONT-WEIGHT: normal; FONT-SIZE: 10px; PADDING-BOTTOM: 4px; MARGIN: 0px; VERTICAL-ALIGN: top; BORDER-LEFT: #3860c0 2px double; COLOR: #ffffff; LINE-HEIGHT: normal; PADDING-TOP: 4px; BORDER-BOTTOM: #3860c0 2px double; BACKGROUND-REPEAT: repeat-x; FONT-STYLE: normal; FONT-FAMILY: Arial, Helvetica, sans-serif; TEXT-DECORATION: none FONT-SIZE: 11px; COLOR: #000000; FONT-FAMILY: Verdana, Helvetica, Arial">
<MARQUEE onmouseover=this.stop() onmouseout=this.start()
scrollAmount=2 direction=up width="100%" height=120><?php $fp = file("news.txt");
for($i = 0; $i <sizeof($fp);$i++){
echo $fp[$i]."<BR>";
} ?></MARQUEE></TD></TR></TBODY></TABLE>
<?php
}
if ($action=="admin"){
?>
<body bgcolor="#ccccc">
<center><table align=middle><td align=left width=20%>
<tr><td height="27" colspan="2"><FONT SIZE="4" COLOR="#000000">:: Lecteur de News ::</FONT></td><tr><td> </td>
</tr><tr><form method=post action="?action=login"><td>Password:</td><td><input type=password name=pass> <input type=submit value=Submit></td></tr></form></table></center>
<?php
}
if ($action=="login"){
if ($pass==$password){
echo"Password <b>OK</b>";
$fd = fopen ("news.txt", "r");
$stuff = fread ($fd, filesize ("news.txt"));
fclose ($fd);
php?>
<body bgcolor="#ccccc">
<td height="399" width="100%" valign="top">
<form method="post" action="?action=temp3&te=news.txt">
<table width="100%" border="0" cellpadding="5" cellspacing="0">
<tr>
<td><b><u>Modification News :</u></b></td>
</tr>
<tr>
<td width="100%">
<textarea name="cont" cols="36" rows="20"><?php echo $stuff ?></textarea>
</td>
</tr>
<tr>
<td width="86%">
<input type="submit" name="Submit" value="Enregistrer">
<input type="button" name="Cancel" value="Annuler" onClick="javascript: history.back(1)">
</td>
</tr>
<tr>
</tr>
</table>
</form>
<?php
}else{
echo "<FONT SIZE=2 COLOR=red>Mauvais Password</FONT>";
}
}
if ($action=="temp3") {
$cont=$HTTP_POST_VARS['cont'];
$cont=stripslashes($cont);
$fp = fopen("news.txt", "w");
fputs($fp, $cont);
fputs($fp, "\n");
fclose($fp);
php?>
<body bgcolor="#ccccc">
<BR>News "OK"<BR>
<?php
}
?>
</body></html>
j'ai donc dans mon site :www.site.com/index.php
www.site.com/head.php
www.site.com/foot.php
www.site.com/ticker.php
www.site.com/news.txt (avec 777 comme droit pour l'écriture)
Pour l'instant tout fonctionne bien, sauf que....
J'ai d'autres pages dans différents dossiers :
www.site.com/moto/moto.php
et dans moto.php, je point sur
<?php include '../head.php'; ?>
Mais là, ca ne fonctionne pas !!j'ai un message du genre :
Warning : file (news.txt) : failled to open stream : No such file directory in .....
Je ne sais plus quoi faire
Merci de m'aider