poston

Problem with UrlEncode

Recommended Posts

Hi,

 

I'm using:

 

$strXML .= "<set label='" . $ors['QuestName'] . "' value='" . $ors2['TotOutput'] . "' link='" . urlencode("Detailed.php?QuestId=". $ors['QuestId']) . "'/>";

 

It works on localhost but not on my site http://qpr.webatu.com

 

Note:

To try it:

- Go to http://qpr.webatu.com

- Click Accès au site

- Click The earth

- Click compte visiteur,

- Click Se loger (use the ID and pwd found)

- Click Format Graph

- Then click a piece of the pie chart

 

Thank you to help me.  :(

Edited by poston

Share this post


Link to post
Share on other sites

..The full code is:

<?php

    $_GET['animate'] = '';   
    $link = connectToDB();
    $animateChart = $_GET['animate']; 
    if ($animateChart=="")
        $animateChart = "1";
    $strXML = "<chart caption='Outputs' subCaption='Nbre de cas' pieSliceDepth='30' showBorder='1' formatNumberScale='0' numberSuffix=' Usager(s)' animation=' " . $animateChart . "'>";
    $strQuery = "select * from Quest_Master";
    $result = mysql_query($strQuery) or die(mysql_error());
 
    if ($result) {
        while($ors = mysql_fetch_array($result)) {           
            $strQuery = "select sum(Quantity) as TotOutput from Quest_Output where QuestId=" . $ors['QuestId']." GROUP BY QuestId";
            $result2 = mysql_query($strQuery) or die(mysql_error()); 
            $ors2 = mysql_fetch_array($result2);           
            $strXML .= "<set label='" . $ors['QuestName'] . "'  value='" . $ors2['TotOutput'] . "'  link='" . urlencode("Detailed.php?QuestId=". $ors['QuestId']) . "'/>";            
            mysql_free_result($result2);
        }
    }
    mysql_close($link);
 
    $strXML .= "</chart>";
    echo renderChart("FusionCharts/Pie3D.swf", "", $strXML, "QuestSum", 600, 300, false, false);
?>

 

The Detailed.php page is:

 

<?php

$QuestId = $_GET['QuestId'];
switch ( $QuestId ) {
        case 1:
        header('Location: detailed1.php');
        break;
        case 2:
        header('Location: detailed2.php');
        break;
        default:
        header('Location: detailed1.php');
        break;
        }
?>

 

The result is:

 

Somebody can help?  :mellow:

Edited by poston

Share this post


Link to post
Share on other sites
Guest Sashibhusan

Hey,

 

Could you please let us know your exact issue, whether the child chart is not rendering at your end?

 

We have tested the URL: http://qpr.webatu.com and the drilled down chart is getting displayed properly, on click of the parent pie slice. (Please see attached screen shot)

 

However, for the "QuestId=2", it seems you have used <space> in between the FusionCharts JavaScript variable "chart_Non satisfaits".

 

Please note that to provide cross-browser compatibility, FusionCharts recommend you not to start the ID with a numerical value, nor use space as part of the ID.

 

So, change the code accordingly and try once again.

 

Awaiting your valuable response.

 

post-23588-0-95156200-1374657479_thumb.png

Share this post


Link to post
Share on other sites

Hi SB

 

Thank you to help me.

Well. Actually I solved the problem in half: it was case sensitive, as follows >>

 

File Detailed.php >>

 

<?php

$QuestId = $_GET['QuestId'];
switch ( $QuestId ) {
        case 1:
        header('Location: detailed1.php');
        break;
        case 2:
        header('Location: detailed2.php');
        break;
        default:
        header('Location: detailed1.php');
        break;
        }
?>
 
The fix is as follows >>
Detailed1.php not detailed1.php

 

And

Detailed2.php not detailed2.php

 

Result:

Detailed1.php is displayed (Table and child graph).

However, the child graph Detailed2.php is not displayed. It displays >>

<chart>

instead.

 

File Detailed2.php is coded like this:

<?php
// On démarre la session (ceci est indispensable dans toutes les pages de notre section membre)
session_start ();  
 //Inclure le fichier de configuration
include "../config.php";
//We've included ../Includes/FusionCharts.php and ../Includes/DBConn.php, which contains
//functions to help us easily embed the charts and connect to a database.
include("Includes/FusionCharts.php");
include("Includes/DBConn.php");
// On récupère nos variables de session
if (isset($_SESSION['login']) && isset($_SESSION['pwd'])) { 
 
      // On teste pour voir si nos variables ont bien été enregistrées
      echo '<html>'; 
      echo '<head>'; 
      echo '<title>Logiciel QPR - Graphes</title>'; 
 
 echo'<SCRIPT LANGUAGE="Javascript" SRC="FusionCharts/FusionCharts.js"></SCRIPT>';
 echo '<link href="../css/style.css" rel="stylesheet" type="text/css">';
 echo '<link href="../css/styles.css" rel="stylesheet" type="text/css">';
 echo '<link rel="shortcut icon" href="../template/img/favicon/favicon.ico" >';
      echo '<link rel="icon" href="../template/img/favicon/animated_favicon.gif" type="image/gif" >
      <link href="../css/style.css" rel="stylesheet" type="text/css">
     <style type="text/css">
     <!--
     body {
 font-family: Arial, Helvetica, sans-serif;
 font-size: 12px;
    }
    .text{
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
    }
table {
         border: medium solid #6495ed;
         border-collapse: collapse;
         width: 83%;
         }
         th {
         font-family: monospace;
         border: thin solid #6495ed;
         width: 50%;
         padding: 5px;
         background-color: #D0E3FA;
         background-image: url(sky.jpg);
         }
        td {
        font-family: sans-serif;
        border: thin solid #6495ed;
        width: 50%;
        padding: 5px;
        text-align: center;
        background-color: #ffffff;
       }
       caption {
       font-family: sans-serif;
       }
    -->
   </style>';
      echo '</head>';  
      echo '<body>';            
?>
 
<?php
include'../header.php';
?>
<div id="ContenuPrincipal">
<center><a href="accueil.php"><img src="../template/img/coolqpr.png" width="550" height="100" alt="Logiciel QPR"></a>
<a href="scu.php">Humanisation</a> 
   <a href="../didacticiel.php">Didacticiels</a>
   <a href="../admin/index.php" target="_blank">cPanel</a>
</center><br>
<center><?php echo '<font color="gray">'.$etab;?></font></center> </h1>  
<hr>
<div style="padding:3px; border:2px dotted #a5a5a5; background-color:black;">
<strong><span class="style8">Important</span></strong><span class="style8"> Ceci est une démo.</span>
</div>
<hr>
<!--SELECTEUR DE TACHES-->
<div style="padding:5px; width:200px; margin:auto; border:4px solid #DBA901; background-color:#848484; -moz-border-radius:20px; -khtml-border-radius:20px; -webkit-border-radius:20px; border-radius:20px;">
<center>
 
<strong><?php echo $_SESSION['login'];?></strong> |
<a href="../accueil.php">Accueil</a> |
<?php 
// On affiche un lien pour fermer notre session
      echo '<a href="../logout.php">Déconnection</a>'; ?> </center>
</div>
<hr> 
<center><h2><font color="white">Etat des usagers non satisfaits (Détails)</font></h2>
<a href='Default.php?animate=0'>Retour</a> <br>
 
<?php
    //This page is invoked from Default.php. When the user clicks on a pie
    //slice in Default.php, the Quest Id is passed to this page. We need
    //to get that Quest id, get information from database and then show
    //a detailed chart.
 
    //Request the Quest Id from Querystring
    $QuestId=2;
    // Connet to the DB
    $link = connectToDB();
    $date = date("Y-m-d h:i:s");
echo '<font color="white">Au</font> <font color="blue">'.$date;
echo' <font color="white">»</font></font>';
    //Tableau
$res = mysql_query("SELECT COUNT(*) FROM quest_output_detailed");
$nb = mysql_fetch_row($res);
echo ' <font color="lime">'.$nb[0].'</font> <font color="white">usager(s) au total</font>'; // $nb est un tableau
 
//Tableau
$sql = "SELECT COUNT(*) AS TOP FROM quest_output_detailed WHERE QuestID=".$QuestId." GROUP BY QuestID";
$res = mysql_query($sql);
if ($res){
$ors = mysql_fetch_array($res);
$top = $ors['TOP'];
echo ' <font color="white">/ Usager(s) concerné(s):</font> <font color="red">'.$top.'</font>';
}
 
$sql_c2 = "SELECT Confort,COUNT(*) AS c2 FROM quest_output_detailed WHERE Confort =-1 GROUP BY Confort";
$res_c2 = mysql_query($sql_c2);
if ($res_c2){
$ors_c2 = mysql_fetch_array($res_c2);
$c2 = $ors_c2['c2'];
 
$sql_h2 = "SELECT Hygiene,COUNT(*) AS h2 FROM quest_output_detailed WHERE Hygiene =-1 GROUP BY Hygiene";
$res_h2 = mysql_query($sql_h2);
if ($res_h2){
$ors_h2 = mysql_fetch_array($res_h2);
$h2 = $ors_h2['h2'];
 
$sql_a2 = "SELECT Alimentation,COUNT(*) AS a2 FROM quest_output_detailed WHERE Alimentation =-1 GROUP BY Alimentation";
$res_a2 = mysql_query($sql_a2);
if ($res_a2){
$ors_a2 = mysql_fetch_array($res_a2);
$a2 = $ors_a2['a2'];
 
$sql_b2 = "SELECT Bruit,COUNT(*) AS b2 FROM quest_output_detailed WHERE Bruit =-1 GROUP BY Bruit";
$res_b2 = mysql_query($sql_b2);
if ($res_b2){
$ors_b2 = mysql_fetch_array($res_b2);
$b2 = $ors_b2['b2'];
 
$sql_d2 = "SELECT Delais,COUNT(*) AS d2 FROM quest_output_detailed WHERE Delais =-1 GROUP BY Delais";
$res_d2 = mysql_query($sql_d2);
if ($res_d2){
$ors_d2 = mysql_fetch_array($res_d2);
$d2 = $ors_d2['d2'];
 
$sql_r2 = "SELECT Rapports,COUNT(*) AS r2 FROM quest_output_detailed WHERE Rapports =-1 GROUP BY Rapports";
$res_r2 = mysql_query($sql_r2);
if ($res_r2){
$ors_r2 = mysql_fetch_array($res_r2);
$r2 = $ors_r2['r2'];
 
$sql_e2 = "SELECT Espaces,COUNT(*) AS e2 FROM quest_output_detailed WHERE Espaces =-1 GROUP BY Espaces";
$res_e2 = mysql_query($sql_e2);
if ($res_e2){
$ors_e2 = mysql_fetch_array($res_e2);
$e2 = $ors_e2['e2'];
 
$sql_f2 = "SELECT Facture,COUNT(*) AS f2 FROM quest_output_detailed WHERE Facture =-1 GROUP BY Facture";
$res_f2 = mysql_query($sql_f2);
if ($res_f2){
$ors_f2 = mysql_fetch_array($res_f2);
$f2 = $ors_f2['f2'];
?>
<table summary="Satisfaits / Non satisfaits">
    <caption><font color="gray">Tableau de données</font></caption>
            <tr>
<th>Critère</th>
            
             <th>Insatisfaction</th>
           </tr>
 
           <tr>
             <td>Confort</td>
 
<td><?php echo $c2;?></td>            
          </tr>
 
          <tr>
            <td>Hygiène</td>
 
<td><?php echo $h2;?></td>
         </tr>
 
<tr>
            <td>Alimentation</td>
             
<td><?php echo $a2;?></td>
         </tr>
 
<tr>
            <td>Bruit</td>
             
<td><?php echo $b2;?></td>
         </tr>
 
<tr>
            <td>Délais</td>
             
<td><?php echo $d2;?></td>
         </tr>
 
<tr>
            <td>Rapports</td>
             
<td><?php echo $r2;?></td>
         </tr>
 
<tr>
            <td>Espaces</td>
             
<td><?php echo $e2;?></td>
         </tr>
 
<tr>
            <td>Facturation</td>
             
<td><?php echo $f2;?></td>
         </tr>
       </table>
  
  <?php
   //Initialize <chart> element
   $strXML="<chart caption='Insatisfaction' subCaption='Tendance' showPercentValues='1' pieSliceDepth='30' showBorder='1'>";
   //Add all data
   $strXML .= "<set label='Confort' value='" . $c2 . "' />";
   $strXML .= "<set label='Hygiene' value='" . $h2 . "' />";
   $strXML .= "<set label='Alimentation' value='" . $a2 . "' />";
   $strXML .= "<set label='Bruit' value='" . $b2 . "' />";
   $strXML .= "<set label='Delais' value='" . $d2 . "' />";
   $strXML .= "<set label='Rapports' value='" . $r2 . "' />";
   $strXML .= "<set label='Espaces' value='" . $e2 . "' />";
   $strXML .= "<set label='Facturation' value='" . $f2 . "' />";
   //Close <chart> element
   $strXML.="</chart>";
 
   //Create the chart - Pie 3D Chart with data from $strXML
   echo renderChart("FusionCharts/Pie3D.swf", "", $strXML, "Non satisfaits", 500, 300, false, false);
  ?>
<?php
}
}
}
}
}
}
}
}
?>
 
<a href='Default.php?animate=0'>Retour</a><br>
<hr>
</div>
<?php include "../footer.php";?>
 
</div>
<?php
}  
else { 
      echo 'Désolé, action interdite..';  
}  
?>
</body>
</html>

 

 

[EDIT]

File Detailed2.php is fixed like this:

<?php
// On démarre la session (ceci est indispensable dans toutes les pages de notre section membre)
session_start ();  
 //Inclure le fichier de configuration
include "../config.php";
//We've included ../Includes/FusionCharts.php and ../Includes/DBConn.php, which contains
//functions to help us easily embed the charts and connect to a database.
include("Includes/FusionCharts.php");
include("Includes/DBConn.php");
// On récupère nos variables de session
if (isset($_SESSION['login']) && isset($_SESSION['pwd'])) { 
 
      // On teste pour voir si nos variables ont bien été enregistrées
      echo '<html>'; 
      echo '<head>'; 
      echo '<title>Logiciel QPR - Graphes</title>'; 
 
 echo'<SCRIPT LANGUAGE="Javascript" SRC="FusionCharts/FusionCharts.js"></SCRIPT>';
 echo '<link href="../css/style.css" rel="stylesheet" type="text/css">';
 echo '<link href="../css/styles.css" rel="stylesheet" type="text/css">';
 echo '<link rel="shortcut icon" href="../template/img/favicon/favicon.ico" >';
      echo '<link rel="icon" href="../template/img/favicon/animated_favicon.gif" type="image/gif" >
      <link href="../css/style.css" rel="stylesheet" type="text/css">
     <style type="text/css">
     <!--
     body {
 font-family: Arial, Helvetica, sans-serif;
 font-size: 12px;
    }
    .text{
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
    }
table {
         border: medium solid #6495ed;
         border-collapse: collapse;
         width: 83%;
         }
         th {
         font-family: monospace;
         border: thin solid #6495ed;
         width: 50%;
         padding: 5px;
         background-color: #D0E3FA;
         background-image: url(sky.jpg);
         }
        td {
        font-family: sans-serif;
        border: thin solid #6495ed;
        width: 50%;
        padding: 5px;
        text-align: center;
        background-color: #ffffff;
       }
       caption {
       font-family: sans-serif;
       }
    -->
   </style>';
      echo '</head>';  
      echo '<body>';            
?>
 
<?php
include'../header.php';
?>
<div id="ContenuPrincipal">
<center><a href="accueil.php"><img src="../template/img/coolqpr.png" width="550" height="100" alt="Logiciel QPR"></a>
<a href="scu.php">Humanisation</a> 
   <a href="../didacticiel.php">Didacticiels</a>
   <a href="../admin/index.php" target="_blank">cPanel</a>
</center><br>
<center><?php echo '<font color="gray">'.$etab;?></font></center> </h1>  
<hr>
<div style="padding:3px; border:2px dotted #a5a5a5; background-color:black;">
<strong><span class="style8">Important</span></strong><span class="style8"> Ceci est une démo.</span>
</div>
<hr>
<!--SELECTEUR DE TACHES-->
<div style="padding:5px; width:200px; margin:auto; border:4px solid #DBA901; background-color:#848484; -moz-border-radius:20px; -khtml-border-radius:20px; -webkit-border-radius:20px; border-radius:20px;">
<center>
 
<strong><?php echo $_SESSION['login'];?></strong> |
<a href="../accueil.php">Accueil</a> |
<?php 
// On affiche un lien pour fermer notre session
      echo '<a href="../logout.php">Déconnection</a>'; ?> </center>
</div>
<hr> 
<center><h2><font color="white">Etat des usagers non satisfaits (Détails)</font></h2>
<a href='Default.php?animate=0'>Retour</a> <br>
 
<?php
    //This page is invoked from Default.php. When the user clicks on a pie
    //slice in Default.php, the Quest Id is passed to this page. We need
    //to get that Quest id, get information from database and then show
    //a detailed chart.
 
    //Request the Quest Id from Querystring
    $QuestId=2;
    // Connet to the DB
    $link = connectToDB();
    $date = date("Y-m-d h:i:s");
echo '<font color="white">Au</font> <font color="blue">'.$date;
echo' <font color="white">»</font></font>';
    //Tableau
$res = mysql_query("SELECT COUNT(*) FROM quest_output_detailed");
$nb = mysql_fetch_row($res);
echo ' <font color="lime">'.$nb[0].'</font> <font color="white">usager(s) au total</font>'; // $nb est un tableau
 
//Tableau
$sql = "SELECT COUNT(*) AS TOP FROM quest_output_detailed WHERE QuestID=".$QuestId." GROUP BY QuestID";
$res = mysql_query($sql);
if ($res){
$ors = mysql_fetch_array($res);
$top = $ors['TOP'];
echo ' <font color="white">/ Usager(s) concerné(s):</font> <font color="red">'.$top.'</font>';
}
 
$sql_c2 = "SELECT Confort,COUNT(*) AS c2 FROM quest_output_detailed WHERE Confort =-1 GROUP BY Confort";
$res_c2 = mysql_query($sql_c2);
if ($res_c2){
$ors_c2 = mysql_fetch_array($res_c2);
$c2 = $ors_c2['c2'];
 
$sql_h2 = "SELECT Hygiene,COUNT(*) AS h2 FROM quest_output_detailed WHERE Hygiene =-1 GROUP BY Hygiene";
$res_h2 = mysql_query($sql_h2);
if ($res_h2){
$ors_h2 = mysql_fetch_array($res_h2);
$h2 = $ors_h2['h2'];
 
$sql_a2 = "SELECT Alimentation,COUNT(*) AS a2 FROM quest_output_detailed WHERE Alimentation =-1 GROUP BY Alimentation";
$res_a2 = mysql_query($sql_a2);
if ($res_a2){
$ors_a2 = mysql_fetch_array($res_a2);
$a2 = $ors_a2['a2'];
 
$sql_b2 = "SELECT Bruit,COUNT(*) AS b2 FROM quest_output_detailed WHERE Bruit =-1 GROUP BY Bruit";
$res_b2 = mysql_query($sql_b2);
if ($res_b2){
$ors_b2 = mysql_fetch_array($res_b2);
$b2 = $ors_b2['b2'];
 
$sql_d2 = "SELECT Delais,COUNT(*) AS d2 FROM quest_output_detailed WHERE Delais =-1 GROUP BY Delais";
$res_d2 = mysql_query($sql_d2);
if ($res_d2){
$ors_d2 = mysql_fetch_array($res_d2);
$d2 = $ors_d2['d2'];
 
$sql_r2 = "SELECT Rapports,COUNT(*) AS r2 FROM quest_output_detailed WHERE Rapports =-1 GROUP BY Rapports";
$res_r2 = mysql_query($sql_r2);
if ($res_r2){
$ors_r2 = mysql_fetch_array($res_r2);
$r2 = $ors_r2['r2'];
 
$sql_e2 = "SELECT Espaces,COUNT(*) AS e2 FROM quest_output_detailed WHERE Espaces =-1 GROUP BY Espaces";
$res_e2 = mysql_query($sql_e2);
if ($res_e2){
$ors_e2 = mysql_fetch_array($res_e2);
$e2 = $ors_e2['e2'];
 
$sql_f2 = "SELECT Facture,COUNT(*) AS f2 FROM quest_output_detailed WHERE Facture =-1 GROUP BY Facture";
$res_f2 = mysql_query($sql_f2);
if ($res_f2){
$ors_f2 = mysql_fetch_array($res_f2);
$f2 = $ors_f2['f2'];
?>
<table summary="Satisfaits / Non satisfaits">
    <caption><font color="gray">Tableau de données</font></caption>
            <tr>
<th>Critère</th>
            
             <th>Insatisfaction</th>
           </tr>
 
           <tr>
             <td>Confort</td>
 
<td><?php echo $c2;?></td>            
          </tr>
 
          <tr>
            <td>Hygiène</td>
 
<td><?php echo $h2;?></td>
         </tr>
 
<tr>
            <td>Alimentation</td>
             
<td><?php echo $a2;?></td>
         </tr>
 
<tr>
            <td>Bruit</td>
             
<td><?php echo $b2;?></td>
         </tr>
 
<tr>
            <td>Délais</td>
             
<td><?php echo $d2;?></td>
         </tr>
 
<tr>
            <td>Rapports</td>
             
<td><?php echo $r2;?></td>
         </tr>
 
<tr>
            <td>Espaces</td>
             
<td><?php echo $e2;?></td>
         </tr>
 
<tr>
            <td>Facturation</td>
             
<td><?php echo $f2;?></td>
         </tr>
       </table>
  
  <?php
   //Initialize <chart> element
   $strXML="<chart caption='Insatisfaction' subCaption='Tendance' showPercentValues='1' pieSliceDepth='30' showBorder='1'>";
   //Add all data
   $strXML .= "<set label='Confort' value='" . $c2 . "' />";
   $strXML .= "<set label='Hygiene' value='" . $h2 . "' />";
   $strXML .= "<set label='Alimentation' value='" . $a2 . "' />";
   $strXML .= "<set label='Bruit' value='" . $b2 . "' />";
   $strXML .= "<set label='Delais' value='" . $d2 . "' />";
   $strXML .= "<set label='Rapports' value='" . $r2 . "' />";
   $strXML .= "<set label='Espaces' value='" . $e2 . "' />";
   $strXML .= "<set label='Facturation' value='" . $f2 . "' />";
   //Close <chart> element
   $strXML.="</chart>";
 
   //Create the chart - Pie 3D Chart with data from $strXML
   echo renderChart("FusionCharts/Pie3D.swf", "", $strXML, "Non_satisfaits", 500, 300, false, false);
  ?>
<?php
}
}
}
}
}
}
}
}
?>
 
<a href='Default.php?animate=0'>Retour</a><br>
<hr>
</div>
<?php include "../footer.php";?>
 
</div>
<?php
}  
else { 
      echo 'Désolé, action interdite..';  
}  
?>
</body>
</html>

 

 

So all work properly now. Many thanks Supreme Being:)

Edited by poston

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now