Précédent   Forum des professionnels en informatique > PHP > Langage > Débuter
Débuter Forum d'entraide pour débuter en PHP. Avant de poster -> Cours PHP, FAQ PHP, Outils PHP, etc.
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 01/04/2011, 11h54   #1
Invité régulier
 
Homme Ila Idias
Inscription : février 2010
Messages : 26
Détails du profil
Informations personnelles :
Nom : Homme Ila Idias
Localisation : Tunisie

Informations forums :
Inscription : février 2010
Messages : 26
Points : 9
Points : 9
Par défaut Utilisation de array_push

Bonjour à tous

Mon petit problème qui m'affiche comme code d'erreur

Citation:
Warning: array_push() [function.array-push]: First argument should be an array in C:\wamp\www\ADCM\imprimer2.php on line 77
FPDF error: Some data has already been output, can't send PDF file
alors que je met au debut de code

$contenuTableau =array();

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 
 
$contenuTableau =array();
$connexion_base =  .................
 
$req = mysql_query("SELECT * FROM candidature ;");
while($donnees = mysql_fetch_array($req)) {
	$nom = $donnees['nom'];
	$prenom = $donnees['prenom'];
	$certif = $donnees['certificat'] ;
	$type =  $donnees['typecertficat'] ;
	$annee =  $donnees['annee'] ;
	$tel =  $donnees['tel'] ;
	$contenuTableau = array_push($contenuTableau ,$nom ,$prenom , $type, $certif, $annee, $tel);
}
$PDF->drawTableau($PDF, $proprietesTableau, $proprieteHeader, $contenuHeader, $proprieteContenu, $contenuTableau );
$PDF->Output();
supupoff est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 01/04/2011, 12h05   #2
Membre éclairé
 
Avatar de beejeridou
 
Homme
Webmaster
Inscription : février 2007
Messages : 261
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France, Bas Rhin (Alsace)

Informations professionnelles :
Activité : Webmaster

Informations forums :
Inscription : février 2007
Messages : 261
Points : 315
Points : 315
Ca donne quoi si tu mets juste

Code :
1
2
 
array_push($contenuTableau ,$nom ,$prenom , $type, $certif, $annee, $tel);
?

Perso j'aurais fait

Code :
1
2
3
4
5
 
$contenuTableau = array();
$req = mysql_query("SELECT * FROM candidature");
$donnees = mysql_fetch_array($req);
array_push($contenuTableau, $donnees);
__________________
Et pourtant... Elle tourne.
http://www.artisan-developpeur.fr
beejeridou est déconnecté   Envoyer un message privé Réponse avec citation 10
Vieux 04/04/2011, 11h11   #3
Invité régulier
 
Homme Ila Idias
Inscription : février 2010
Messages : 26
Détails du profil
Informations personnelles :
Nom : Homme Ila Idias
Localisation : Tunisie

Informations forums :
Inscription : février 2010
Messages : 26
Points : 9
Points : 9
il m'affiche les données commme ça
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Notice: Array to string conversion in C:\wamp\www\ADCM\phpToPDF.php on line 1347
 
Notice: Undefined offset: 1 in C:\wamp\www\ADCM\phpToPDF.php on line 1330
 
Notice: Undefined offset: 2 in C:\wamp\www\ADCM\phpToPDF.php on line 1330
 
Notice: Undefined offset: 3 in C:\wamp\www\ADCM\phpToPDF.php on line 1330
 
Notice: Array to string conversion in C:\wamp\www\ADCM\phpToPDF.php on line 901
 
Notice: Undefined index: 97 in C:\wamp\www\ADCM\phpToPDF.php on line 923
 
Notice: Undefined index: Saidi in C:\wamp\www\ADCM\phpToPDF.php on line 923
 
Notice: Undefined index: Ali in C:\wamp\www\ADCM\phpToPDF.php on line 923
 
Notice: Undefined index: Informatique appliqée à la gestion in C:\wamp\www\ADCM\phpToPDF.php on line 923
 
Notice: Undefined index: 4 ans (Maitrise) in C:\wamp\www\ADCM\phpToPDF.php on line 923
erreur

Code :
1
2
Notice: Array to string conversion in C:\wamp\www\ADCM\fpdf.php on line 810
FPDF error: Some data has already been output, can't send PDF file
supupoff est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/04/2011, 13h14   #4
Membre confirmé
 
Avatar de sayari.dev
 
Homme Marouen Sayari
Développeur Web
Inscription : mai 2010
Messages : 142
Détails du profil
Informations personnelles :
Nom : Homme Marouen Sayari
Localisation : Algérie

Informations professionnelles :
Activité : Développeur Web

Informations forums :
Inscription : mai 2010
Messages : 142
Points : 225
Points : 225
Code :
$contenuTableau = array_push($contenuTableau ,$nom ,$prenom , $type, $certif, $annee, $tel);
A la 1ère exécution, ça passe bien. Et vu que array_push retourne le nouveau nombre d'éléments dans le tableau, ton $contenuTableau n'est plus un array mais plutôt un entier (int), d'où la provenance du warning

Citation:
Warning: array_push() [function.array-push]: First argument should be an array in C:\wamp\www\ADCM\imprimer2.php on line 77
Donc tu dois changer l'instrcution ci-dessus par une simple

Code :
array_push($contenuTableau ,$nom ,$prenom , $type, $certif, $annee, $tel);
__________________
C'est en faisant n'importe quoi qu'on devient n'importe qui
sayari.dev est déconnecté   Envoyer un message privé Réponse avec citation 10
Vieux 04/04/2011, 14h36   #5
Invité régulier
 
Homme Ila Idias
Inscription : février 2010
Messages : 26
Détails du profil
Informations personnelles :
Nom : Homme Ila Idias
Localisation : Tunisie

Informations forums :
Inscription : février 2010
Messages : 26
Points : 9
Points : 9
Par défaut 10kx

Citation:
Envoyé par sayari.dev Voir le message
Code :
$contenuTableau = array_push($contenuTableau ,$nom ,$prenom , $type, $certif, $annee, $tel);
A la 1ère exécution, ça passe bien. Et vu que array_push retourne le nouveau nombre d'éléments dans le tableau, ton $contenuTableau n'est plus un array mais plutôt un entier (int), d'où la provenance du warning
Merci pour l'explication c très mieux que le bon réponse



Donc tu dois changer l'instrcution ci-dessus par une simple
Citation:
Envoyé par sayari.dev Voir le message

Code :
array_push($contenuTableau ,$nom ,$prenom , $type, $certif, $annee, $tel);
Résolu et merci beaucoup encore
supupoff est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 04h10.


 
 
 
 
Partenaires

Hébergement Web