Liste deroulante avec PEAR

Résolu
LiLou LiLa Messages postés 330 Date d'inscription   Statut Membre Dernière intervention   -  
LiLou LiLa Messages postés 330 Date d'inscription   Statut Membre Dernière intervention   -
Bonjour,
j'aimerai savvoir comment faire pour creer une liste deroulante en utilisant pear

en php j'ai :

echo "<select name='ref' size=1>";


while ($lig2=mysql_fetch_row($res2))

	{

		echo'<option value='.$lig2[0].'>'.$lig2[0].'</option>';

	}
echo "</select>";

?>


c'ets pareil en pear??

MERCI D'AVANCE
A voir également:

7 réponses

Jeren Messages postés 256 Date d'inscription   Statut Membre Dernière intervention   45
 
Salut!
Te revoila ^^
Comme je te l'ai deja dit PEAR est un framework, et ça ne va pas changer la façon de faire une liste déroulante. Donc ta liste déroulante est très bien comme elle est.
Par contre je me demandais l'interet de mettre tes select en echo?!?

echo "<select name='ref' size=1>";
echo "</select>";
0
LiLou LiLa Messages postés 330 Date d'inscription   Statut Membre Dernière intervention   12
 
coucou :)
t'es attiré par mes soucis de codage dis donc :p

je sais pas pour les select, comme ça ou autrement c'est casi pareil ^^
l'interet c'est pour si ya pas de resultat rien afficher mais bon je le fais pas ça :p

donc je laisse ma liste comme ça :)

jai un soucis, un message d'erreur ; ça viendrait de la connexion mais je sais pas quoi faire pour arranger ça

Fatal error: Call to undefined function: assertextension() in /usr/share/pear/DB/mssql.php on line 79
0
Jeren Messages postés 256 Date d'inscription   Statut Membre Dernière intervention   45
 
Bah t'appelles une fonction qu'il ne trouve pas.
Et en effet, elle n'est pas dans /usr/share/pear/DB/mssql.php
0
LiLou LiLa Messages postés 330 Date d'inscription   Statut Membre Dernière intervention   12
 
quel fonction?
mon code c'est :
<?php

error_reporting(E_ALL);

include ("connexion.php");

?>


et connexion.php c'est :

<?php

require_once('DB.php');
$dbType="mysql";
$host="*******";
$account="***";
$pass="***";
$dbName="cartouche";
$dsn=$dbType."://".$account.":".$pass."@".$host."/".$dbName;


$db = DB::connect($dsn);

if (DB::isError($db)){
echo"ERREUR :".$db->getMessage();
}
?>
0
LiLou LiLa Messages postés 330 Date d'inscription   Statut Membre Dernière intervention   12 > LiLou LiLa Messages postés 330 Date d'inscription   Statut Membre Dernière intervention  
 
DB.php est avec mes pages du site
0
Jeren Messages postés 256 Date d'inscription   Statut Membre Dernière intervention   45
 
Regarde dans DB.php si il y a la fonction assertextension() !
0
LiLou LiLa Messages postés 330 Date d'inscription   Statut Membre Dernière intervention   12
 
jai fait dans lediteur de texte rechercher >assertextension()
il ne trouve rien
0
Jeren Messages postés 256 Date d'inscription   Statut Membre Dernière intervention   45
 
Le voila le probleme!!
Dans mon db.php je l'ai cette fonction, et visiblement il te la manque...
Je te la passe t'as qu'a l'insérer...

function assertExtension($name)
{
if (!extension_loaded($name)) {
$dlext = OS_WINDOWS ? '.dll' : '.so';
$dlprefix = OS_WINDOWS ? 'php_' : '';
@dl($dlprefix . $name . $dlext);
return extension_loaded($name);
}
return true;
}

Il faut que tu l'inseres dans la classe DB
0
LiLou LiLa Messages postés 330 Date d'inscription   Statut Membre Dernière intervention   12
 
moi dans class DB j'ai :

class DB
{
        function &factory($type, $options = false)
    {
        if (!is_array($options)) {
            $options = array('persistent' => $options);
        }

        if (isset($options['debug']) && $options['debug'] >= 2) {
            // expose php errors with sufficient debug level
            include_once "DB/{$type}.php";
        } else {
            @include_once "DB/{$type}.php";
        }

        $classname = "DB_${type}";

        if (!class_exists($classname)) {
            $tmp = PEAR::raiseError(null, DB_ERROR_NOT_FOUND, null, null,
                                    "Unable to include the DB/{$type}.php"
                                    . " file for '$dsn'",
                                    'DB_Error', true);
            return $tmp;
        }

        @$obj = new $classname;

        foreach ($options as $option => $value) {
            $test = $obj->setOption($option, $value);
            if (DB::isError($test)) {
                return $test;
            }
        }

        return $obj;
    }


je le rajoute après ton truc?
0
LiLou LiLa Messages postés 330 Date d'inscription   Statut Membre Dernière intervention   12 > LiLou LiLa Messages postés 330 Date d'inscription   Statut Membre Dernière intervention  
 
je lai mis après et il me repond maintenant
ERREUR :DB Error: connect failed


qui est le message d'erreur après la connexion :

if (DB::isError($db))
{
	echo"ERREUR :".$db->getMessage();
}
?>
0
Jeren Messages postés 256 Date d'inscription   Statut Membre Dernière intervention   45 > LiLou LiLa Messages postés 330 Date d'inscription   Statut Membre Dernière intervention  
 
T'es sous Linux ou Windows?
0
LiLou LiLa Messages postés 330 Date d'inscription   Statut Membre Dernière intervention   12 > Jeren Messages postés 256 Date d'inscription   Statut Membre Dernière intervention  
 
heu ubuntu :o
0
Jeren Messages postés 256 Date d'inscription   Statut Membre Dernière intervention   45 > LiLou LiLa Messages postés 330 Date d'inscription   Statut Membre Dernière intervention  
 
Et t'as pris wamp????????
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
Jeren Messages postés 256 Date d'inscription   Statut Membre Dernière intervention   45
 
Je t'aurai bien copié la mienne, mais elle fait plus de 500 lignes...
Bah oui rajoute le apres!
0
LiLou LiLa Messages postés 330 Date d'inscription   Statut Membre Dernière intervention   12
 
wooh merci c'est bon ca marche :)

le serveur etait en plus pas connecté :p hi hi

et là ça va :)
merci beaucoup !!!

mais jai pleins de fautes sur mon code
0
Jeren Messages postés 256 Date d'inscription   Statut Membre Dernière intervention   45 > LiLou LiLa Messages postés 330 Date d'inscription   Statut Membre Dernière intervention  
 
Pour une fois que j'arrive à t'aider!!! ^^
Mets les erreurs ici pour voir si je suis dans un bon jour.
0
LiLou LiLa Messages postés 330 Date d'inscription   Statut Membre Dernière intervention   12 > Jeren Messages postés 256 Date d'inscription   Statut Membre Dernière intervention  
 
while($result=$rsc->fetchRow(DB_FETCHMODE_ASSOC))
	{
		echo"<tr><td>".$result[0]."</td><td>".$result[1]."</td><td>".$result[2]."</td></tr>";
	}
?> 


l'erreur est sur la ligne du echo blabla
0
LiLou LiLa Messages postés 330 Date d'inscription   Statut Membre Dernière intervention   12 > Jeren Messages postés 256 Date d'inscription   Statut Membre Dernière intervention  
 
while($result=$rsc->fetchRow(DB_FETCHMODE_ASSOC))
{
echo "<tr><td>$result[0]</td><td>$result[1]</td></tr>";
}



l'erreur :


Fatal error: Call to undefined function: fetchrow() in /var/www/Portail_Logistique/cartouchesite/choixref.php on line 31
0
Jeren Messages postés 256 Date d'inscription   Statut Membre Dernière intervention   45
 
L'erreur n'est pas sur la ligne echo mais sur la ligne du dessus, tu appelles la fonction fetchrow() qui est inconnu!
0
LiLou LiLa Messages postés 330 Date d'inscription   Statut Membre Dernière intervention   12
 
tu veux vraiment le savoir :o .... c'est parti :

Notice: Undefined offset: 0 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 1 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 2 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 0 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 1 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 2 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 0 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 1 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 2 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 0 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 1 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 2 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 0 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 1 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 2 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 0 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 1 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 2 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 0 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 1 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 2 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 0 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 1 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 2 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 0 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 1 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 2 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 0 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 1 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 2 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 0 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 1 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 2 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 0 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 1 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 2 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 0 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 1 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 2 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 0 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 1 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 2 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 0 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 1 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 2 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 0 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 1 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 2 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 0 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 1 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 2 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 0 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 1 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 2 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 0 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 1 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 2 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 0 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 1 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 2 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 0 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 1 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 2 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 0 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 1 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46
Notice: Undefined offset: 2 in /var/www/Portail_Logistique/cartouchesite/liste.php on line 46


tout ca :) (ligne 46 = echo blabla)

c'est un peu repititif mais c'est mes messages d'erreurs
0
LiLou LiLa Messages postés 330 Date d'inscription   Statut Membre Dernière intervention   12
 
ce'st pour une autre page celui là :p
0
kij_82 Messages postés 4089 Date d'inscription   Statut Contributeur Dernière intervention   857 > LiLou LiLa Messages postés 330 Date d'inscription   Statut Membre Dernière intervention  
 
Re,

Tes erreurs sont normales, tu as cette ligne de code :
while($result=$rsc->fetchRow(DB_FETCHMODE_ASSOC)){
}


Or, que peux tu remarquer dans ton test ? Tu fais une AFFECTATION et non un test, ce qui est donc toujours TRUE, donc ta boucle est toujours vérifiée !
Or, comme dis plus haut, la fonction fetchRow n'existe pas, conclusion la valeur 'null' est attribuée à ta variable $result, du coup lorsque tu tente d'accèder à ce qu'il y a dedans (cf $result[0], [1], [2]), tu as l'erreur comme quoi l'offset 0, 1, 2 sont inconnus (puisque ta variable est nulle)

Conclusion, ajoute un test dans ta boucle comme ceci :
while( ($result=$rsc->fetchRow(DB_FETCHMODE_ASSOC)) != null ){
}


Et puis bien sur il faut modifier la fonction appelée si elle n'existe pas (fetchRow)
0
LiLou LiLa Messages postés 330 Date d'inscription   Statut Membre Dernière intervention   12 > kij_82 Messages postés 4089 Date d'inscription   Statut Contributeur Dernière intervention  
 
trop fort mes erreurs sont partis

par contre le tableau qui s'affiche est totalement vide pourquoi?
0
LiLou LiLa Messages postés 330 Date d'inscription   Statut Membre Dernière intervention   12
 
comment ca se fait que fetchrow soit inconnu ??
il marche sur l'autre fichier ( ou y avait le probleme !=null)
pourtant c 'est ecrit pareil
0
LiLou LiLa Messages postés 330 Date d'inscription   Statut Membre Dernière intervention   12
 
oui yavait ça et autre chose
c'est bon ça marche :)

<?//liste deroulante pour selection par reference

$rsc2=$db->query("SELECT Distinct IdReference FROM sorties;");

if(DB::isError($rsc2))
die($rsc2->getMessage());

echo "Selection par reference de cartouche";
echo "<form action=\"choixref.php\" method=\"post\">";
echo "<select name=\"ref\" size=1>";

while ($row2=$rsc2->fetchRow())
	{
	echo"<option value='".$row2[0]."'>".$row2[0]."</option>";

	}
echo "</select>";
echo "<input type=\"submit\" name=\"valideref\" value=\"Rechercher\">";

echo "</form>";
?>


il ne prenait pas ma requete jai un soucis avec la table , aucune requete ne marche dessus
mais pour ça c'est bon ;)

merci beaucoup
0