Rechercher : dans
Par :

Erreur php

Dernière réponse le 21 oct 2009 à 16:09:55 gbemich, le 21 oct 2009 à 15:17:04 
 Signaler ce message aux modérateurs

Bonjour,
je développe un site web et pour le lancer j'appelle une page dans l'index et les autres liens me permettent d'afficher d'autres pages.Seulement quand je lance l'index il y a une notice qui s'affiche m'indiquant que j'ai pas déclaré p:
Voici le code de l'index:
<?php
session_start();
header("Cache-control: private");
?>
<?php

require("dbconnect.php");
$db = new dbconnect();
$db->connect();

?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Acceuil</title>
<link href="style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.Style3 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-weight: bold;
color: #800000;
}
-->
</style>
<script language="JavaScript" src="calendar1.js"></script>
</head>

<body bgcolor="#336699">
<?php
if(isset($_GET['$p'])){
$p=$_GET['$p'];
}
?>
</head>

<body bgcolor="#336699">
<table height="1" cellSpacing="0" cellPadding="0" width="705" align="center" border="0">
<tbody>
<tr>
<td align="middle" width="705" bgColor="#cadcee" height="1">
<table style="BORDER-COLLAPSE: collapse" borderColor="#0099cc" height="1" cellSpacing="0" cellPadding="0" width="750" bgColor="#ffffff" border="1">
<tbody>
<tr>
<td vAlign="top" align="middle" bgColor="#003366" height="1">
<table id="AutoNumber2" style="BORDER-COLLAPSE: collapse" borderColor="#111111" height="15" cellSpacing="3" cellPadding="0" width="102%" border="0">
<tbody>
<tr>
<td width="100%" bgColor="#003366" colSpan="3" height="1">
<div align="left">
<table border="0" width="100%" height="89">
<tr>
<td width="100%" background="orange.gif" height="21"> </td>
</tr>
<tr>
<td width="100%" height="62"><p align="right"> <img src="btn-volshotel.gif" width="162" height="101">     <img src="vols-hp_02.gif" width="489" height="78">

<div align="center">
<center>
<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td width="100%" bgcolor="#0080FF"><p align="left" class="Style3"> KAISER  VOYAGES...</p>
<p align="right" class="Style3">...COMME DANS VOS REVES </p>
<div align="center"> </div>
</td>
</tr>
</table>
</center>
</div>
</td>
</tr>
<tr>
<td width="100%" background="orange.gif" height="1"><div align="right"><strong><a href="<?php echo 'index.php?$p=33' ?>">Contacts</a></strong></div></td>
</tr>
</table>
</div>
</td>
</tr>
<center>
<tr>
<td vAlign="top" width="22%" bgColor="#003366" height="175">
<table border="0" width="100%">
<tr>
<td width="100%">
<?php include("includmenu.php"); ?></td>
</tr>
</table>
</td>
</center>
<td vAlign="top" width="100%" bgColor="#FFFFFF" height="87">
<center>
<div align="left">
<?php

switch($p){
case 1:include("p1.php"); break;
case 2:include("p2.php"); break;
case 3:include("p3.php"); break;
case 4:include("p4.php"); break;
case 5:include("p5.php"); break;
case 6:include("p6.php"); break;
case 7:include("p7.php"); break;
case 8:include("p8.php"); break;
case 9:include("p9.php"); break;
case 10:include("p10.php"); break;
case 11:include("p11.php"); break;
case 12:include("p12.php"); break;
case 13:include("p13.php"); break;
case 14:include("p14.php"); break;
case 15:include("p15.php"); break;
case 16:include("p16.php"); break;
case 17:include("p17.php"); break;
case 18:include("p18.php"); break;
case 19:include("p19.php"); break;
case 20:include("p20.php"); break;
case 21:include("p21.php"); break;
case 22:include("p22.php"); break;
case 23:include("p23.php"); break;
case 24:include("p24.php"); break;
case 25:include("p25.php"); break;
case 26:include("p26.php"); break;
case 27:include("p27.php"); break;
case 28:include("p28.php"); break;
case 29:include("p29.php"); break;
case 30:include("p30.php"); break;
case 31:include("p31.php"); break;
case 32:include("p32.php"); break;
case 33:include("p33.php"); break;
case 34:include("p34.php"); break;
case 35:include("p35.php"); break;
case 36:include("includmenu.php"); break;
case 37:include("menu2.php"); break;
case 38:include("menu3.php"); break;
default:include("p1.php"); break;
}
?>
</div>
</center>
</td>
</tr>
</tbody>
</table>
<table border="0" width="100%">
<tr>
<td width="100%" background="orange.gif">
<p align="center"><font size="2">All Rights Reserved-Copyright 2009 </font></td>
</tr>
</table>

</table>
</table>

</body>

Et voici l'erreur qui vient kan g lance le site:
Notice: Undefined variable: p in C:\wamp\www\agence_voyage\index.php on line 98

Notice: Undefined variable: p in C:\wamp\www\agence_voyage\index.php on line 99

Notice: Undefined variable: p in C:\wamp\www\agence_voyage\index.php on line 100

Notice: Undefined variable: p in C:\wamp\www\agence_voyage\index.php on line 101

Notice: Undefined variable: p in C:\wamp\www\agence_voyage\index.php on line 102

Notice: Undefined variable: p in C:\wamp\www\agence_voyage\index.php on line 103

Notice: Undefined variable: p in C:\wamp\www\agence_voyage\index.php on line 104

Notice: Undefined variable: p in C:\wamp\www\agence_voyage\index.php on line 105

Notice: Undefined variable: p in C:\wamp\www\agence_voyage\index.php on line 106

Notice: Undefined variable: p in C:\wamp\www\agence_voyage\index.php on line 107

Notice: Undefined variable: p in C:\wamp\www\agence_voyage\index.php on line 108

Notice: Undefined variable: p in C:\wamp\www\agence_voyage\index.php on line 109

Notice: Undefined variable: p in C:\wamp\www\agence_voyage\index.php on line 110

Notice: Undefined variable: p in C:\wamp\www\agence_voyage\index.php on line 111

Notice: Undefined variable: p in C:\wamp\www\agence_voyage\index.php on line 112

Notice: Undefined variable: p in C:\wamp\www\agence_voyage\index.php on line 113

Notice: Undefined variable: p in C:\wamp\www\agence_voyage\index.php on line 114

Notice: Undefined variable: p in C:\wamp\www\agence_voyage\index.php on line 115

Notice: Undefined variable: p in C:\wamp\www\agence_voyage\index.php on line 116

Notice: Undefined variable: p in C:\wamp\www\agence_voyage\index.php on line 117

Notice: Undefined variable: p in C:\wamp\www\agence_voyage\index.php on line 118

Notice: Undefined variable: p in C:\wamp\www\agence_voyage\index.php on line 119

Notice: Undefined variable: p in C:\wamp\www\agence_voyage\index.php on line 120

Notice: Undefined variable: p in C:\wamp\www\agence_voyage\index.php on line 121

Notice: Undefined variable: p in C:\wamp\www\agence_voyage\index.php on line 122

Notice: Undefined variable: p in C:\wamp\www\agence_voyage\index.php on line 123

Notice: Undefined variable: p in C:\wamp\www\agence_voyage\index.php on line 124

Notice: Undefined variable: p in C:\wamp\www\agence_voyage\index.php on line 125

Notice: Undefined variable: p in C:\wamp\www\agence_voyage\index.php on line 126

Notice: Undefined variable: p in C:\wamp\www\agence_voyage\index.php on line 127

Notice: Undefined variable: p in C:\wamp\www\agence_voyage\index.php on line 128

Notice: Undefined variable: p in C:\wamp\www\agence_voyage\index.php on line 129

Notice: Undefined variable: p in C:\wamp\www\agence_voyage\index.php on line 130

Notice: Undefined variable: p in C:\wamp\www\agence_voyage\index.php on line 131

Notice: Undefined variable: p in C:\wamp\www\agence_voyage\index.php on line 132

Notice: Undefined variable: p in C:\wamp\www\agence_voyage\index.php on line 133

Notice: Undefined variable: p in C:\wamp\www\agence_voyage\index.php on line 134

Notice: Undefined variable: p in C:\wamp\www\agence_voyage\index.php on line 135
la page s'affiche après.
SVP aidez moi

Configuration: Windows Vista
Firefox 3.5.3

Meilleures réponses pour « erreur php » dans :
[PHP] Notice: Undefined index: VoirSi vous utilisez les tableaux $_POST ou $_GET pour récupérer les variables de vos formulaires ou autres, il se peut que vous tombiez sur cette erreur: Notice: Undefined index 'champs du tableau' in 'chemin du fichier php en cours d'execution' on line...
Cacher les erreurs en PHP VoirRappelons avant toute chose, qu'il est toujours préférable, dans n'importe quel langage de programmation, de corriger les problèmes qui déclenchent les erreurs, avant d'essayer de masquer les erreurs. En effet, le fait de masquer les erreurs...
[PHP] Méthodes de débogage VoirI. Informations sur une variable I.1 echo I.2 print_r() I.3 var_dump() / var_export() I.4 Rediriger la sortie (ne pas afficher à l'écran) II. "Backtrace" ou rapport de contexte III. Bien utiliser les rapports d'erreur IV. Le mot clé...
PHP - Les fichiers VoirLa gestion des fichiers avec PHP Avec PHP, la création ou la lecture de fichiers est, une fois de plus, assez simple. Il existe une multitude de fonctions dédiées à l'utilisation des fichiers. La communication entre le script PHP et le fichier...

1

avion-f16, le 21 oct 2009 à 15:24:02

<?php
if(isset($_GET['$p'])){
$p=$_GET['$p'];
}
?>
ce que tu mets entre les crochets n'est pas une variable mais une clé pour un tableau associatif et une valeur pour un tableau simple. Tu ne dois donc pas mettre $p mais p

<?php echo 'index.php?$p=33'; ?>
Tu ne doit pas mettre le signe dollar ! Ton ordinateur ne fait pas ce que tu veux ... mais ce que tu lui dis de faire.

Répondre à avion-f16

2

Nabla's, le 21 oct 2009 à 15:24:27

Je pense qu'il faut modifier ca:
<?php
if(isset($_GET['$p'])){
$p=$_GET['$p'];
}
?>

en ca

<?php
if(isset($_GET['p'])){
$p=$_GET['p'];
}
else
$p=1;//la valeur par défaut
?>

Répondre à Nabla's

3

papouuu86, le 21 oct 2009 à 15:24:27

Deja <a href="<?php echo 'index.php?$p=33' ?>">Contacts</a> enleve le $ devant ton p il ne sert à rien

il faut que tu déclares ton $p avant ton $_GET pour qu'il renvoie à une page par defaut. car si $_GET['p'] n'existe pas alors ton $p non plus du coup ton switch ne sert a rien..

Répondre à papouuu86

4

zoby44, le 21 oct 2009 à 15:28:19

Salut, j'avais pas vu ce que dit avion-f16, mais c'est pas faux.
Il faut aussi que tu attribue une valeur à $p même si le get n'est pas présent.

if(isset($_GET['p'])){
$p = $_GET['p'];
}
else {
$p = 0;
}

Il est souvent plus rapide de chercher que d'attendre une réponse... Google est notre ami.
Mettez vos codes entre les bonnes balises ( les "<>" au dessus de la zone de texte )

Répondre à zoby44

5

papouuu86, le 21 oct 2009 à 15:31:15

Je dirais qu'il vaudrait mieux pour toi de mettre une valeur de ton switch car comme dis si $_GET[p] n'existe pas $p vaudra 0 or il n'y a pas de cas ou $p=0 dans ton switch.. attribue la valeur de ta page par defaut

Répondre à papouuu86

6

gbemich, le 21 oct 2009 à 16:06:29

Merci à tous .j'ai trouvé l'erreur:
il fallait modifier ca:
<?php
if(isset($_GET['$p'])){
$p=$_GET['$p'];
}
?>

en ca

<?php
if(isset($_GET['$p'])){
$p=$_GET['$p'];
}
else
$p=1;//la valeur par défaut
?>
_______________________________________________________

Répondre à gbemich

8

 Nabla's, le 21 oct 2009 à 16:09:55

Comme dit plus haut, les $ n'ont rien à faire dans l'url, ni dans le $_GET['$p']

ce n'est pas vraiment faut en soit, mais c'est super moche, et dans le cas s'utilisation des variables globales, ca risque de merdouiller

Répondre à Nabla's

7

papouuu86, le 21 oct 2009 à 16:09:49

Enleve le $ devant ton p dans ton $_GET
comme on te l'a tous dit

Répondre à papouuu86