IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Bibliothèques et frameworks PHP Discussion :

[JPgraph] et la connexion de BD


Sujet :

Bibliothèques et frameworks PHP

  1. #1
    Membre du Club
    Femme Profil pro
    Formateur en informatique
    Inscrit en
    Avril 2011
    Messages
    78
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Maroc

    Informations professionnelles :
    Activité : Formateur en informatique

    Informations forums :
    Inscription : Avril 2011
    Messages : 78
    Points : 43
    Points
    43
    Par défaut [JPgraph] et la connexion de BD
    Bonjour,

    J'utilise jpgraph pour la création des graphes sous php, tout est bien jusqu'à maintenant, mais lorsque je sépare la connexion de la base de données et le graphe je trouve des problèmes, c'est à dire j'ai crée un fichier du nom connexion.php et je fais l'appel dans mon graphe.

    Même la requête est correcte (je teste sous phpMysql) lorsque j'exécute il m'affiche : Pb de requête:

    voici le code de fichier connexion.php:


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    <?php
     
    define('MYSQL_HOST', 'localhost');
    define('MYSQL_USER', 'root');
    define('MYSQL_PASS', '');
    define('MYSQL_DATABASE', 'asterisk');
     
    $mysqlCnx = @mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS) or die('Pb de connxion mysql');
     
    @mysql_select_db(MYSQL_DATABASE) or die('Pb de sélection de la base');
     
    ?>

    code du graphe:


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    <?php
     
    include ("jpgraph/src/jpgraph.php");
    include ("jpgraph/src/jpgraph_bar.php");
     
    $tab_wait = array();
    $tab_talk = array();
    $tab_pause = array();
    $tab_dead = array();
    $tab_dispo = array();
    $tableauuser = array();
    include("connexion.php");
    $sql_ventes_par_produits = 
    "
    SELECT     sum(wait_sec) as w, sum(dispo_sec) as d, 
               sum(talk_sec) as t, sum(pause_sec) as p, 
               sum(dead_sec) as de, full_name
    FROM       `vicidial_users` as vu, vicidial_agent_log as val
    where       vu.user=val.user 
    
    group by   full_name "
    ;
     
    $mysqlQuery = @mysql_query($sql_ventes_par_produits, $db) or die('Pb de requête: ' . mysql_error());
    mysql_close();
    while ($row_type_user = mysql_fetch_array($mysqlQuery,  MYSQL_ASSOC)) { 
    	$tab_wait[] = $row_type_user['w'];
    	$tab_dispo[] = $row_type_user['d'];
    	$tab_pause[] = $row_type_user['p'];
    	$tab_talk[] = $row_type_user['t'];
    	$tab_dead[] = $row_type_user['de'];
    	$tableauuser[] = $row_type_user['full_name'];
    }
     
     
    // *******************
    // Création du graphique
    // *******************
     
    // Construction du conteneur
    // Spécification largeur et hauteur
    $graph = new Graph(1000,500);
     
    // Réprésentation linéaire
    $graph->SetScale("textlin");
     
    // Ajouter une ombre au conteneur
    //$graph->SetShadow();
     
    // Fixer les marges
    $graph->img->SetMargin(60,30,25,140);
     
    // Chaque histogramme sera placé dans un tableau commun 
    $aGroupBarPlot = array();
    //Histo 1
     
    $bplot = new BarPlot($tab_wait);
    $bplot->SetFillGradient('blue', '#9090FF', GRAD_VER);
    $bplot->SetLegend('wait');
    $bplot->value->Show();
    $bplot->value->SetFont(FF_ARIAL, FS_NORMAL,7);
    $bplot->value->SetColor('black');
    $bplot->value->SetFormat('%d');
    $aGroupBarPlot[] = $bplot;
    //Histo 2
    $bplot2 = new BarPlot($tab_dispo);
    $bplot2->SetFillGradient('blue', '#90FF90', GRAD_VER);
    $bplot2->SetLegend('dispo');
    $bplot2->value->Show();
    $bplot2->value->SetFont(FF_ARIAL, FS_NORMAL,7);
    $bplot2->value->SetColor('black');
    $bplot2->value->SetFormat('%d');
    $aGroupBarPlot[] = $bplot2; 
    //Histo 3
    $bplot3 = new BarPlot($tab_talk);
    $bplot3->SetFillGradient('green', '#90FF90', GRAD_VER);
    $bplot3->SetLegend('talk');
    $bplot3->value->Show();
    $bplot3->value->SetFont(FF_ARIAL, FS_NORMAL,7);
    $bplot3->value->SetColor('black');
    $bplot3->value->SetFormat('%d');
    $aGroupBarPlot[] = $bplot3; 
    //Histo 4
    $bplot4 = new BarPlot($tab_dead);
    $bplot4->SetFillGradient('violet', '#90FF90', GRAD_VER);
    $bplot4->SetLegend('dead');
    $bplot4->value->Show();
    $bplot4->value->SetFont(FF_ARIAL, FS_NORMAL,7);
    $bplot4->value->SetColor('black');
    $bplot4->value->SetFormat('%d');
    $aGroupBarPlot[] = $bplot4; 
    //Histo 5
    $bplot5 = new BarPlot($tab_pause);
    $bplot5->SetFillGradient('white', '#FF9090', GRAD_VER);
    $bplot5->SetLegend('pause');
    $bplot5->value->Show();
    $bplot5->value->SetFont(FF_ARIAL, FS_NORMAL,7);
    $bplot5->value->SetColor('black');
    $bplot5->value->SetFormat('%d');
    $aGroupBarPlot[] = $bplot5;
     
    //Objet qui regroupe les histogrammes
    $gbarplot = new GroupBarPlot($aGroupBarPlot);
     
    // Spécification des couleurs des barres
    $bplot->SetFillColor('red');
    $bplot2->SetFillColor('blue');
    $bplot3->SetFillColor('green');
    $bplot4->SetFillColor('violet');
    $bplot5->SetFillColor('white');
     
    // Afficher les valeurs pour chaque barre
    $bplot->value->Show();
    // Fixer l'aspect de la police
    $bplot->value->SetFont(FF_ARIAL,FS_NORMAL,9);
    // Modifier le rendu de chaque valeur
    $bplot->value->SetFormat('%d');
     
    // Le titre
    $graph->title->Set("Graphique 'HISTOGRAMME' ");
    $graph->title->SetFont(FF_FONT1,FS_BOLD);
     
    // Titre pour l'axe horizontal(axe x) et vertical (axe y)
    //$graph->xaxis->title->Set("Années");
    //$graph->yaxis->title->Set("Nombre de ventes");
     
    $graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
    $graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
     
    // Légende pour l'axe horizontal
    $graph->xaxis->SetTickLabels($tableauuser);
    $graph->xaxis->SetFont(FF_ARIAL,FS_NORMAL,8); 
    $graph->xaxis->SetLabelAngle(50);
     
    // Ajouter au graphique les 2 histos
    $graph->Add($gbarplot);
     
    // Afficher
    $graph->Stroke();
     
    ?>
    Merci d'avance pour votre aide.

  2. #2
    Membre expert
    Avatar de Spartacusply
    Homme Profil pro
    Développeur Web
    Inscrit en
    Mai 2011
    Messages
    1 723
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mai 2011
    Messages : 1 723
    Points : 3 274
    Points
    3 274
    Par défaut
    Enlève TOUS les arobases, c'est ce qui fait que ton message d'erreur n'apparaît pas (j'ai jamais compris pourquoi php avait donné cette possibilité de ne pas retourner les messages d'erreurs...).

    Tu en saura après un peu plus sur la nature de ton erreur.

    Au passage, l'extension mysql est obsolète (bientôt supprimée), il est recommandé dès à présent d'utiliser l'extension mysqli ou PDO
    Un message utile vous a aidé ? N'oubliez pas le

    www.simplifions.fr - Simplifier vos comptes entre amis !

  3. #3
    Membre du Club
    Femme Profil pro
    Formateur en informatique
    Inscrit en
    Avril 2011
    Messages
    78
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Maroc

    Informations professionnelles :
    Activité : Formateur en informatique

    Informations forums :
    Inscription : Avril 2011
    Messages : 78
    Points : 43
    Points
    43
    Par défaut
    merci pour votre réponse.


    il m'affiche un erreur : Nom : img.PNG
Affichages : 110
Taille : 29,4 Ko

  4. #4
    Membre du Club
    Femme Profil pro
    Formateur en informatique
    Inscrit en
    Avril 2011
    Messages
    78
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Maroc

    Informations professionnelles :
    Activité : Formateur en informatique

    Informations forums :
    Inscription : Avril 2011
    Messages : 78
    Points : 43
    Points
    43
    Par défaut
    j'ai supprimé mysqlclose(); et il m'affiche L'image “http://localhost/histo22.php” ne peut être affichée car elle contient des erreurs.
    je ne sais ou exactement cet erreur

Discussions similaires

  1. [JPgraph] Problème avec la connexion de la base de données
    Par infooo dans le forum Bibliothèques et frameworks
    Réponses: 1
    Dernier message: 15/03/2014, 19h08
  2. [JpGraph] Générer un graphique JPGraph avec une connexion PostGres
    Par Grégory_60 dans le forum Bibliothèques et frameworks
    Réponses: 4
    Dernier message: 22/12/2012, 20h59
  3. Réponses: 4
    Dernier message: 04/07/2002, 12h31
  4. Connexion ODBC
    Par Anonymous dans le forum Réseau
    Réponses: 2
    Dernier message: 23/04/2002, 12h10
  5. Je ne peux établir une connexion cliente sous Linux.
    Par Anonymous dans le forum CORBA
    Réponses: 5
    Dernier message: 16/04/2002, 15h57

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo