I will explain my error: I have a form where I type an email shortly after it sends to ConexaoDB.php this page, I store the entered value, connect the PostgreSQL go into the users table and when the email entered and found I store the value in a variable coluna_empresa. and this variable has the same name as a database in MySQL, make sure the connection Mysql, so far so good when I try to take a more include ('ConexaoDB.php') in my page to generate a graph have the following errors:
when I open at the same time: This "http: //localhost/grafico/example.mysql2.php" contains errors and can not be displayed.
After having sent the values:
Notice: Undefined index: email in /var/www/grafico/db/ConexaoDB.php on line 11
Notice: Undefined variable: nome in /var/www/grafico/db/ConexaoDB.php on line 26
No database selected
I need you guys help. put the codes below:
example.mysql2.php:
<?php
/* Incluindo classes do pChart */
include("class/pData.class.php");
include("class/pDraw.class.php");
include("class/pImage.class.php");
include("db/ConexaoDB.php");
/* Criando o objeto pData */
$myData = new pData();
/* Construindo a consulta e retornando os dados para o grafico*/
$Requete = "SELECT * FROM `marca`";
$Result = mysql_query($Requete);
$cod=""; $bom=""; $regular=""; $ruim="";
while($row = mysql_fetch_array($Result))
{
/* Puxando os resultados da consulta em um array*/
$cod[] = $row["cod_pesquisa"];
$bom[] = $row["bom_twitter"];
$regular[] = $row["regular_twitter"];
$ruim[] = $row["ruim_twitter"];
}
/* Salvando os dados no array pData*/
$myData->addPoints($cod,"Cod");
$myData->addPoints($bom,"Gostou");
$myData->addPoints($regular,"Indiferente");
$myData->addPoints($ruim,"Nao gostou");
//Definindo um sistema de cores das barras
$myData->loadPalette("palettes/notion.color",TRUE);
/* Colocando a coluna cod_pesquisa como eixo das abscissa*/
$myData->setAbscissa("Cod");
/* Declarando o eixo Y e dando seu nome */
$myData->setAxisName(0,"Twetts");
/*Criando um objeto pChart*/
$myPicture = new pImage(700,230,$myData);
/*Configurando o fundo da imagem*/
$myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL,array("StartR"=>40,"StartG"=>40,"StartB"=>40,"EndR"=>80,"EndG"=>80,"EndB"=>80,"Alpha"=>100));
//Cabeçalho da imagem
$myPicture->drawGradientArea(0,0,700,35,DIRECTION_HORIZONTAL,array("StartR"=>0,"StartG"=>0,"StartB"=>0,"EndR"=>0,"EndG"=>0,"EndB"=>0,"Alpha"=>220));
/* Adicionando bordas a imagem */
$myPicture->drawRectangle(0,0,699,229,array("R"=>0,"G"=>0,"B"=>0));
/* Selecionando sistemas da fonte */
$myPicture->setFontProperties(array("R"=>255,"G"=>255,"B"=>255,"FontName"=>"fonts/pf_arma_five.ttf","FontSize"=>6));
/*Criando titulo */
$myPicture->drawText(220,25,"Analise de Sentimento - Marca",array("FontSize"=>15,"Align"=>TEXT_ALIGN_BOTTOMMIDDLE, "R"=>255,"G"=>255,"B"=>255));
/* Definindo a área do gráfico */
$myPicture->setGraphArea(60,40,650,200);
/* Desenhando a escala */
$scaleSettings = array("GridR"=>50,"GridG"=>50,"GridB"=>50,"DrawSubTicks"=>TRUE,"CycleBackground"=>TRUE);
$myPicture->drawScale($scaleSettings);
/* Escrevendo a area da legenda */
$myPicture->drawLegend(520,12,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL));
/* Ligando sombras */
$myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>5));
/* Desenhando grafico */
$settings = array("Gradient"=>TRUE,"GradientMode"=>GRADIENT_EFFECT_CAN,"DisplayPos"=>LABEL_POS_INSIDE,"DisplayValues"=>TRUE,"DisplayR"=>255,"DisplayG"=>255,"DisplayB"=>255,"DisplayShadow"=>TRUE);
$myPicture->drawBarChart($settings);
/* Fazendo a imagem ( Escolha um bom caminho para a imagem) */
$myPicture->autoOutput("example.mysql.png");
?>
ConexaoDB.php:
<?php
require_once"Conexao.classPg.php";
require_once "Conexao.classMysql.php";
$conexao = New Conexao;
//conexao PostgreSql
$conexao->conectarPostgreSql();
$email = $_POST['email'];
$sql = "SELECT nome_empresa FROM cadastros.usuarios where email = '".$email."' ";
$query = pg_query($sql);
while ($sql = pg_fetch_array($query)){
$nome = $sql ['nome_empresa'];
}
//conexao Mysql
$conexao2 = New ConexaoMysql;
$conexao2->servidor = 'localhost';
$conexao2->usuario = 'root';
$conexao2->senha = 'sap';
$conexao2->db = $nome;
$conexao2->conectar();
$conexao2->selectDB();
?>