Précédent   Forum des professionnels en informatique > PHP > Langage > Syntaxe
Syntaxe Forum d'entraide sur la syntaxe de PHP et la POO. Avant de poster -> FAQ syntaxe, Cours d'initiation et cours de POO
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 07/06/2011, 11h55   #1
Invité de passage
 
Homme joris
Étudiant
Inscription : juin 2011
Messages : 36
Détails du profil
Informations personnelles :
Nom : Homme joris
Localisation : France, Hérault (Languedoc Roussillon)

Informations professionnelles :
Activité : Étudiant
Secteur : High Tech - Matériel informatique

Informations forums :
Inscription : juin 2011
Messages : 36
Points : 1
Points : 1
Par défaut erreur pour ma liste déroulante

Code :
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
<?php
 $config=array(
  'Database'=>'*****',
  'UID'=>'***',
  'PWD'=>'******');
$idconnect=sqlsrv_connect('(local)',$config);
    if( $idconnect === false )
{
     echo "Could not connect.\n";
     die( print_r( sqlsrv_errors(), true));
}
$result=sqlsrv_query($idconnect,'SELECT codeinfo,nom FROM Tclientordon order by nom asc ');
 
 
echo '<form name="selection" action="proto_php_sqlserver.php" method="post">
<select name="liste_deroulante">';
while($nini=sqlsrv_fetch_array($result))
{
    echo '<option value="' . $nini['codeinfo'] . '">' . htmlentities($nini['nom']) . '</option>';
}
echo '</select>
<input type="submit" value="OK">
</form>';
 
while($nini=sqlsrv_fetch_array($result))
{
  echo '<option value='. $nini['nom']}.'-'.{$nini['codeinfo']}.">" . htmlentities($nini['nom']) . '</option>'
}
 if (isset($_POST['liste_deroulante']))
{
  list($nom, $codeinfo) = explode('-', $_POST['liste_deroulante']);
}
 
?>
cela m'indique que j'ai une erreur partiel ligne 29; je souhaite afficher les nom ainsi que le code info quand je clique sur un nom dans ma liste déroulante
si quelqu'un peu m'aider je lui en serait très reconnaissant
djolah13 est déconnecté   Envoyer un message privé Réponse avec citation 01
Vieux 07/06/2011, 12h33   #2
Futur Membre du Club
 
Femme
Développeur Web
Inscription : janvier 2011
Messages : 16
Détails du profil
Informations personnelles :
Sexe : Femme
Localisation : France

Informations professionnelles :
Activité : Développeur Web

Informations forums :
Inscription : janvier 2011
Messages : 16
Points : 18
Points : 18
Ligne 27 il te manque le ";" en fin de ligne
ninog est déconnecté   Envoyer un message privé Réponse avec citation 10
Vieux 07/06/2011, 14h12   #3
Invité de passage
 
Homme joris
Étudiant
Inscription : juin 2011
Messages : 36
Détails du profil
Informations personnelles :
Nom : Homme joris
Localisation : France, Hérault (Languedoc Roussillon)

Informations professionnelles :
Activité : Étudiant
Secteur : High Tech - Matériel informatique

Informations forums :
Inscription : juin 2011
Messages : 36
Points : 1
Points : 1
j'ai rajouté le ';' mais même après sa, sa me dit toujours:

Citation:
Notice: Undefined offset: 1 in C:\wamp\www\php_proto\proto_php_sqlserver.php on line 34
00691
// c'est le code info que je compté ressortir
djolah13 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 07/06/2011, 14h20   #4
Invité de passage
 
Homme joris
Étudiant
Inscription : juin 2011
Messages : 36
Détails du profil
Informations personnelles :
Nom : Homme joris
Localisation : France, Hérault (Languedoc Roussillon)

Informations professionnelles :
Activité : Étudiant
Secteur : High Tech - Matériel informatique

Informations forums :
Inscription : juin 2011
Messages : 36
Points : 1
Points : 1
voici ma ligne 30 à 36:
Code :
1
2
3
4
5
6
7
8
 
}
 
if (isset($_POST['liste_deroulante']))
{
  list($nom, $codeinfo) = explode('-', $_POST['liste_deroulante']);
}
echo $nom.' '.$codeinfo;
djolah13 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 07/06/2011, 14h54   #5
Membre régulier
 
Homme
Développeur Web
Inscription : octobre 2009
Messages : 72
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : Vietnam

Informations professionnelles :
Activité : Développeur Web

Informations forums :
Inscription : octobre 2009
Messages : 72
Points : 99
Points : 99
Citation:
Envoyé par djolah13 Voir le message
voici ma ligne 30 à 36:
Code :
1
2
3
4
5
6
7
8
 
}
 
if (isset($_POST['liste_deroulante']))
{
  list($nom, $codeinfo) = explode('-', $_POST['liste_deroulante']);
}
echo $nom.' '.$codeinfo;
Salut, fais l'echo de $nom ds la condition
matlow est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 07/06/2011, 15h43   #6
Invité de passage
 
Homme joris
Étudiant
Inscription : juin 2011
Messages : 36
Détails du profil
Informations personnelles :
Nom : Homme joris
Localisation : France, Hérault (Languedoc Roussillon)

Informations professionnelles :
Activité : Étudiant
Secteur : High Tech - Matériel informatique

Informations forums :
Inscription : juin 2011
Messages : 36
Points : 1
Points : 1
j'ai mis l'echo dans la condition toujours pareil
Citation:
Notice: Undefined offset: 1 in C:\wamp\www\php_proto\proto_php_sqlserver.php on line 34
+le codeinfo qui s'affiche
djolah13 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 07/06/2011, 16h32   #7
Futur Membre du Club
 
Femme
Développeur Web
Inscription : janvier 2011
Messages : 16
Détails du profil
Informations personnelles :
Sexe : Femme
Localisation : France

Informations professionnelles :
Activité : Développeur Web

Informations forums :
Inscription : janvier 2011
Messages : 16
Points : 18
Points : 18
Ça donne quoi si tu fais un echo de
Code :
 $_POST['liste_deroulante']
juste avant le explode ? Tu es sûr que sa valeur est formatée comme tu l'attends ?
ninog est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 07/06/2011, 16h46   #8
Invité de passage
 
Homme joris
Étudiant
Inscription : juin 2011
Messages : 36
Détails du profil
Informations personnelles :
Nom : Homme joris
Localisation : France, Hérault (Languedoc Roussillon)

Informations professionnelles :
Activité : Étudiant
Secteur : High Tech - Matériel informatique

Informations forums :
Inscription : juin 2011
Messages : 36
Points : 1
Points : 1
si je fais:
Code :
1
2
3
4
5
6
7
 
if (isset($_POST['liste_deroulante']))
{
 echo $_post['liste_deroulante']; 
  list($nom, $codeinfo) = explode('-', $_POST['liste_deroulante']);
 
echo $nom.' '.$codeinfo;
cela me donne:
Citation:
Notice: Undefined variable: _post in C:\wamp\www\php_proto\proto_php_sqlserver.php on line 34

Notice: Undefined offset: 1 in C:\wamp\www\php_proto\proto_php_sqlserver.php on line 35
00608
djolah13 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 07/06/2011, 16h49   #9
Invité de passage
 
Homme joris
Étudiant
Inscription : juin 2011
Messages : 36
Détails du profil
Informations personnelles :
Nom : Homme joris
Localisation : France, Hérault (Languedoc Roussillon)

Informations professionnelles :
Activité : Étudiant
Secteur : High Tech - Matériel informatique

Informations forums :
Inscription : juin 2011
Messages : 36
Points : 1
Points : 1
désolé erreur syntaxe cela me donne maintenant ma liste déroulante quand je clic sur un nom puis sur OK cela me donne
Citation:
05107 //codeinfo
Notice: Undefined offset: 1 in C:\wamp\www\php_proto\proto_php_sqlserver.php on line 35
05107 //codeinfo
djolah13 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 07/06/2011, 22h07   #10
Membre régulier
 
Homme
Développeur Web
Inscription : octobre 2009
Messages : 72
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : Vietnam

Informations professionnelles :
Activité : Développeur Web

Informations forums :
Inscription : octobre 2009
Messages : 72
Points : 99
Points : 99
Je n'avais pas vu, tu fais 2 boucles qui retournant un html différent et la 2eme est hors du formulaire
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?php
 echo '<form name="selection" action="proto_php_sqlserver.php" method="post">
<select name="liste_deroulante">';
while($nini=sqlsrv_fetch_array($result))
{
    echo '<option value="' . $nini['codeinfo'] . '">' . htmlentities($nini['nom']) . '</option>';
}
echo '</select>
<input type="submit" value="OK">
</form>';
 
while($nini=sqlsrv_fetch_array($result))
{
  echo '<option value='. $nini['nom']}.'-'.{$nini['codeinfo']}.">" . htmlentities($nini['nom']) . '</option>'
}
 
?>
Pourquoi ne fais-tu pas simplement ceci :
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php
 echo '<form name="selection" action="proto_php_sqlserver.php" method="post">
<select name="liste_deroulante">';
while($nini=sqlsrv_fetch_array($result))
{
  echo '<option value='. $nini['nom'].'-'.{$nini['codeinfo'].">" . htmlentities($nini['nom']) . '</option>';
}
echo '</select>
<input type="submit" value="OK">
</form>';
 
 
 
?>
matlow est déconnecté   Envoyer un message privé Réponse avec citation 10
Vieux 08/06/2011, 10h40   #11
Invité de passage
 
Homme joris
Étudiant
Inscription : juin 2011
Messages : 36
Détails du profil
Informations personnelles :
Nom : Homme joris
Localisation : France, Hérault (Languedoc Roussillon)

Informations professionnelles :
Activité : Étudiant
Secteur : High Tech - Matériel informatique

Informations forums :
Inscription : juin 2011
Messages : 36
Points : 1
Points : 1
je ne pense pas que les problèmes viennent de la pour cette erreur
djolah13 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 08/06/2011, 10h49   #12
Membre régulier
 
Homme
Développeur Web
Inscription : octobre 2009
Messages : 72
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : Vietnam

Informations professionnelles :
Activité : Développeur Web

Informations forums :
Inscription : octobre 2009
Messages : 72
Points : 99
Points : 99
Citation:
Envoyé par djolah13 Voir le message
Notice: Undefined offset: 1 in C:\wamp\www\php_proto\proto_php_sqlserver.php on line 35
05107 //codeinfo
C'est peut-être que tu ne renseignes pas la bonne valeur ds l'option du form
(il manque $nini['nom'])
Code :
1
2
 
  echo '<option value="' . $nini['codeinfo'] . '">' . htmlentities($nini['nom']) . '</option>';
matlow est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 08/06/2011, 14h06   #13
Invité de passage
 
Homme joris
Étudiant
Inscription : juin 2011
Messages : 36
Détails du profil
Informations personnelles :
Nom : Homme joris
Localisation : France, Hérault (Languedoc Roussillon)

Informations professionnelles :
Activité : Étudiant
Secteur : High Tech - Matériel informatique

Informations forums :
Inscription : juin 2011
Messages : 36
Points : 1
Points : 1
je viens d’essayer,
toujours la même erreur
Code :
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
<?php
 $config=array(
  'Database'=>'******',
  'UID'=>'***',
  'PWD'=>'*******');
$idconnect=sqlsrv_connect('(local)',$config);
    if( $idconnect === false )
{
     echo "Could not connect.\n";
     die( print_r( sqlsrv_errors(), true));
}
$result=sqlsrv_query($idconnect,'SELECT codeinfo,nom FROM clientordon order by nom asc ');
 
 
echo '<form name="selection" action="proto_php_sqlserver.php" method="post">
<select name="liste_deroulante">';
while($nini=sqlsrv_fetch_array($result))
{
echo '<option value="' . $nini['codeinfo'] . '">' . htmlentities($nini['nom']) . '</option>';
 
}
echo '</select>
<input type="submit" value="OK">
</form>';
 
while($nini=sqlsrv_fetch_array($result))
{
  echo '<option value='. $nini['nom'].'-'.$nini['codeinfo'].">" . htmlentities($nini['nom']);
 
}
 
 
if (isset($_POST['liste_deroulante']))
{
echo $_POST['liste_deroulante']; 
  list($nom, $codeinfo) = explode('-', $_POST['liste_deroulante']);
 
echo $nom.' '.$codeinfo;
}
 
 
 
?>
erreur:

Citation:
93013 //codeinfo
Notice: Undefined offset: 1 in C:\wamp\www\php_proto\proto_php_sqlserver.php on line 38
93013 //codeinfo
djolah13 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 08/06/2011, 14h47   #14
Futur Membre du Club
 
Femme
Développeur Web
Inscription : janvier 2011
Messages : 16
Détails du profil
Informations personnelles :
Sexe : Femme
Localisation : France

Informations professionnelles :
Activité : Développeur Web

Informations forums :
Inscription : janvier 2011
Messages : 16
Points : 18
Points : 18
Ce que propose matlow est juste, le deuxième while n'a pas lieu d'être : tu écris des en dehors du formulaire.
ninog est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 08/06/2011, 15h15   #15
Invité de passage
 
Homme joris
Étudiant
Inscription : juin 2011
Messages : 36
Détails du profil
Informations personnelles :
Nom : Homme joris
Localisation : France, Hérault (Languedoc Roussillon)

Informations professionnelles :
Activité : Étudiant
Secteur : High Tech - Matériel informatique

Informations forums :
Inscription : juin 2011
Messages : 36
Points : 1
Points : 1
c'est a dire
je suis plutôt; vraiment débutant, je galere
djolah13 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 15/06/2011, 16h13   #16
Membre éclairé
 
Homme Jérémy
Étudiant
Inscription : octobre 2009
Messages : 236
Détails du profil
Informations personnelles :
Nom : Homme Jérémy
Localisation : France

Informations professionnelles :
Activité : Étudiant
Secteur : High Tech - Produits et services télécom et Internet

Informations forums :
Inscription : octobre 2009
Messages : 236
Points : 322
Points : 322
Pas trop le temps de lire mais à mon avis comme ça déjà tu y arriverais mieux.

Code :
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
<?php
 $config=array(
  'Database'=>'******',
  'UID'=>'***',
  'PWD'=>'*******');
$idconnect=sqlsrv_connect('(local)',$config);
    if( $idconnect === false )
{
     echo "Could not connect.\n";
     die( print_r( sqlsrv_errors(), true));
}
$result=sqlsrv_query($idconnect,'SELECT codeinfo,nom FROM clientordon order by nom asc ');
 
 
echo '<form name="selection" action="proto_php_sqlserver.php" method="post">
<select name="liste_deroulante">';
while($nini=sqlsrv_fetch_array($result))
{
  echo '<option value='. $nini['nom'].'-'.$nini['codeinfo'].">" . htmlentities($nini['nom']);
 
}
echo '</select>
<input type="submit" value="OK">
</form>';
 
 
 
if (isset($_POST['liste_deroulante']))
{
echo $_POST['liste_deroulante']; 
  list($nom, $codeinfo) = explode('-', $_POST['liste_deroulante']);
 
echo $nom.' '.$codeinfo;
}
 
 
 
?>
Une seule liste déroulante dans le form et renvoyant nom et codeinfo.
gwharl est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 20h31.


 
 
 
 
Partenaires

Hébergement Web