Ooops, I think I left some extra PHP code in there that shouldn't be.
Delete these lines and try again:
$query1 = $db->prepare("SELECT * FROM testpower WHERE datetime > 0");
$query1 ->execute();
$results1 = $query1->fetchAll(PDO::FETCH_ASSOC);
If it still doesn't work, you may have luck running it from the command
line instead of a browser. The command line output will show you any PHP
errors. If you are working in a Linux environment, you can use the PHP
command line tool, eg:
php /path/to/script.php
I don't know if that is available on the Windows version of PHP or not. If
you use this, you will have to hard-code your query inputs, as there is no
way to feed data to $_GET from the command line.
On Tuesday, December 18, 2012 12:19:13 AM UTC-5, Chrystopher Medina wrote:
>
> this is my script my friend but it doesnt work ,,,, and it doesnt show an
> error just the page keep loading and loading and nothing
>
> <?php
> $var1=$_POST['fecha1'];
> $var2= $_POST['fecha2'];
>
> $server="localhost";
> $username="root";
> $password="chrystopher";
> $databasename="encuestasavandaro";
>
> try{
> $db = new PDO("mysql:dbname=$databasename", $username, $password);
>
> }
> catch (PDOException $e){
> die("{error: {$e ->getMessage()}}");
> }
> $db->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
> $query1 = $db->prepare("SELECT * FROM testpower WHERE datetime > 0");
> $query1 ->execute();
> $results1 = $query1->fetchAll(PDO::FETCH_ASSOC);
>
> $query = $db->prepare("
> SELECT b.id_respuesta , COUNT(b.id_respuesta) AS cnt, b.id_aspecto
> FROM huesped a, rompe_encuesta b
> WHERE
> b.id_huesped = a.id_huesped AND b.id_aspecto >= 1 AND b.id_aspecto <= 33
> AND
> a.fecha BETWEEN :fecha1 AND :fecha2
> GROUP BY b.id_respuesta, b.id_aspecto
> ");
>
> $parameters = array(
>
> 'fecha1' => $var1,
> 'fecha2' => $var2
>
> );
> try{
> $query->execute($parameters);
> $results = $query->fetchAll(PDO::FETCH_ASSOC);
> }catch (PDOException $e){
> die("{error: {$e->getMessage()}}");
> }
>
> $table = array();
>
> $table['cols']=array(
> array('label' => 'Type' , 'type' => 'string'),
> array('label' => 'Count' , 'type' => 'number'),
> array('label' => 'Aspecto', 'type' => 'number')
> );
>
> $rows = array();
>
> foreach ($results as $r){
> $temp = array();
> // using (int) $variable typecasts the variable as an integer, usefull
> when the SQL is returning numbers as strings
>
> switch ((int) $r['id_respuesta']) {
>
> case 1:
> $type='excelente';
> break;
> case 2:
> $type='bueno';
> break;;
> case 3:
> $type='regular';
> break;
> case 4:
> $type='malo';
> break;
> case 5:
> $type='si';
> break;
> case 6:
> $type='no';
> break;
> case 7:
> $type='no respondio';
> break;
> case 8:
> $type = 'recomendación';
> break;
> case 9:
> $type = 'anuncio de revista';
> break;
> case 10:
> $type = 'letrero carretera';
> break;
> case 11:
> $type = 'google';
> break;
> case 12:
> $type = 'directo al hotel';
> break;
> case 13:
> $type = 'llamada al 800';
> break;
> case 14:
> $type = 'sitio web del hotel';
> break;
> case 15:
> $type = 'sitio web de otros';
> break;
> case 16:
> $type = 'agencia de viajes';
> break;
> case 17:
> $type = 'otros';
> break;
>
> default:
> die('{"error":"Error in SQL query: unknown \'id_respuesta\'"}');
> }
>
> $temp[] = array('v' => $type." =".$r['cnt']);
> $temp[] = array('v' => (int) $r['cnt']);
> $temp[] = array('v' => (int) $r['id_aspecto']);
> $rows[] = array('c' => $temp);
> }
> $table['rows'] = $rows;
> $jsonTable = json_encode($table);
>
> header('Cache-Control: no-cache, must-revalidate');
> header('Expires: Mon, 26 Jul 1997 05:00:00 GTM');
>
> header('Content-type: application/json');
>
> echo $jsonTable;
>
>
> ?>
>
>
>
>
>
>
>
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-visualization-api/-/_5B-zeYVN8MJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-visualization-api?hl=en.