Sanuna 0 Denunciar post Postado Junho 16, 2011 Oi gente, estou a tentar criar um grafico com a ferramenta phplot e com base de dados, mas não esta a funcionar. Depois de testar o codigo, aparece uma mensagem a dizer que a imagem contém erros. Envio o codigo para ver se me conseguem ajudar ;) <?php include('LIGALABVIEW.php'); include('phplot/phplot.php'); $table="angulo"; $query=mysql_query("select * from $table"); $linhas=mysql_num_rows($query); for($i=0;$i<$linhas;$i++) { $array[]=array(mysql_result ($query, $i,'temp'),mysql_result($query,$i,'ang')); } $plot=new PHPlot (800, 600); $plot->SetImageBorderType ('plain'); $plot->SetPlotType('lines'); $plot->SetDataType('text-data'); $plot->SetDataValues($array); $plot->SetTitle('Posição angular vs Tempo'); $plot->SetXTitle('Tempo'); $plot->SetBackgroundColor('white'); $plot->SetLegend(array('temp')); $plot->SetXTickLabelPos('none'); $plot->SetXTickPos('none'); $plot->DrawGraph(); ?> Não percebo o que pode estar mal :x SOCORROOOOOOOO :ermm: Compartilhar este post Link para o post Compartilhar em outros sites
Kakashi_Hatake 267 Denunciar post Postado Junho 16, 2011 Qual é a mensagem de erro ? Verifique se não existe impressão de tela( linha em branco, texto, etc...) antes da imagem. Faça um teste unitário. <?php require( 'phplot/phplot.php' ); $plot = new PHPlot(); $example_data = array( array('a',3), array('b',5), array('c',7), array('d',8), array('e',2), array('f',6), array('g',7) ); $plot->SetDataValues($example_data); $plot->SetXTickLabelPos('none'); $plot->SetXTickPos('none'); $plot->DrawGraph(); ?> Compartilhar este post Link para o post Compartilhar em outros sites
Sanuna 0 Denunciar post Postado Junho 16, 2011 Antes de mais muito obrigada pelo tempo dispensado! A mensagem de erro é a seguinte: The image http://localhost:8888/grafLab.php cannot be displayed because it contains errors. :ermm: Compartilhar este post Link para o post Compartilhar em outros sites
Kakashi_Hatake 267 Denunciar post Postado Junho 16, 2011 você verificou se existe impressão de tela ? Fez o teste em separado ? Compartilhar este post Link para o post Compartilhar em outros sites
Sanuna 0 Denunciar post Postado Junho 18, 2011 Sim, ao testar o exemplo que me mandou, funciona na perfeição! Já tinha testado outro exemplo semenhante antes, e tambem funcionava! :( :( não percebo porque nao esta a funcionar, parece-me tudo bem :x Compartilhar este post Link para o post Compartilhar em outros sites
Kakashi_Hatake 267 Denunciar post Postado Junho 18, 2011 Verifique se o array está sendo montado corretamente. Segue outro teste funcionando. <?php include( 'phplot/phplot.php' ); $array = array( array( 'a', 1 ), array( 'b', 3 ), array( 'c', 2 ), array( 'd', 7 ), array( 'e', 6 ), array( 'f', 9 ) ); $plot = new PHPlot( 800, 600 ); $plot->SetImageBorderType( 'plain' ); $plot->SetPlotType( 'lines' ); $plot->SetDataType( 'text-data' ); $plot->SetDataValues( $array ); $plot->SetTitle( 'Posição angular vs Tempo' ); $plot->SetXTitle( 'Tempo' ); $plot->SetBackgroundColor( 'white' ); $plot->SetLegend( array( 'temp' ) ); $plot->SetXTickLabelPos( 'none' ); $plot->SetXTickPos( 'none' ); $plot->DrawGraph( ); ?> Compartilhar este post Link para o post Compartilhar em outros sites
Sanuna 0 Denunciar post Postado Junho 19, 2011 Funciona também! :x Não sei que mais fazer! Compartilhar este post Link para o post Compartilhar em outros sites
Kakashi_Hatake 267 Denunciar post Postado Junho 19, 2011 você ainda não respondeu minhas perguntas anteriores. <_< Existe impressão de tela( linha em branco, texto, etc...) antes da imagem ? O array está sendo montado corretamente ? Compartilhar este post Link para o post Compartilhar em outros sites
Sanuna 0 Denunciar post Postado Junho 19, 2011 Me desculpe! Não existe impressão de tela e o vector esta montado correctamente! Compartilhar este post Link para o post Compartilhar em outros sites
Kakashi_Hatake 267 Denunciar post Postado Junho 19, 2011 O que contém neste arquivo LIGALABVIEW.php, verificou se nele possui algum tipo de impressão de tela. Te pergunto, pois nos testes que te passei você disse que funciona então o problema deve estar em outro arquivo que está sendo incluido neste. Compartilhar este post Link para o post Compartilhar em outros sites
Sanuna 0 Denunciar post Postado Junho 20, 2011 Envio o ficheiro LIGALABVIEW.php: <head> <title> Ligação </title> </head> <body> <?php $host='localhost'; $user='root'; $pass=''; $db='labview'; $table='angulo'; $link=mysql_connect($host, $user, $pass) or die ("Não ligou"); $sel=mysql_select_db($db); if($sel==0) { $criar=mysql_query("Create database $db"); $sel1=mysql_select_db($db); $criar1=mysql_query("Create table $table (temp float(10), ang float(10))"); } else { if(mysql_query('SELECT * from $table')==0) { mysql_query("create table $table (temp float(10), ang float(10))"); } } ?> </body> </html> Verifiquei ate com um colega, e nada parece errado --' Compartilhar este post Link para o post Compartilhar em outros sites
Kakashi_Hatake 267 Denunciar post Postado Junho 20, 2011 Percebeu que você está imprimindo na tela tags HTML. Remova as tags HTML e os espaços antes e depois do código e teste novamente. <?php $host = 'localhost'; $user = 'root'; $pass = ''; $db = 'labview'; $table = 'angulo'; $link = mysql_connect( $host, $user, $pass ) or die ( "Não ligou" ); $sel = mysql_select_db( $db ); if( $sel == 0 ) { $criar = mysql_query( "Create database $db" ); $sel1 = mysql_select_db( $db ); $criar1 = mysql_query( "Create table $table (temp float(10), ang float(10))" ); } else { if( mysql_query( 'SELECT * from $table' ) == 0 ) { mysql_query( "create table $table (temp float(10), ang float(10))" ); } } ?> Compartilhar este post Link para o post Compartilhar em outros sites
Sanuna 0 Denunciar post Postado Junho 20, 2011 eich :) meu deus! voce acredita que nem meu engenheiro da faculdade conseguiu dar com esse erro? nossa, muito obrigada viu ;) :joia: :joia: :clap: :clap: Compartilhar este post Link para o post Compartilhar em outros sites