Several suggestions ;-) :

1) create a new script called pi.php and put just this inside:

<?php phpinfo(); ?>

Then put it on your web root and access the script. You'll see the
neat phpinfo() page...look for the "session" part and make sure that
you have these values:

Session Support:        enabled
session.auto_start      On      On

If this is not like that, you're sessions are not enabled!

Solution: edit php.ini and enable session.

2) Make sure that the $x_data is comming in a format that jpgraph can
handle (array()).

3) Go to app/config/core.php and set

define('DEBUG', 3);

Refresh the browser page and look at the gibberish just below the page
(on page A) and make sure that all data that you're setting on the
session is comming in the correct format from the controller.

Note: the 'gibberish' is actually the dump of the VIEW objects...  :-)

4) Report feedback here, please!!

I suggested you all these steps because of the foreach error
message...I got a couple as well on my project and they were related
to two things:

a) PHP _SESSION not properly set
b) data in a bad format between controller/view/plot-script

Good luck!!

Cheers!








On Feb 15, 3:26 am, "YoLoL" <[EMAIL PROTECTED]> wrote:
> Hi, I have been trying as you suggested but I got into this issue:
> when I put the data into a session variable and try to access this
> from the script that generates the graphic; it gets there without
> anydata.
>
> I checked if the session has been started already and it is.
>
> The code works well as a standalone but when I try to use it with a
> IMG tag it won't work... any suggestion?
>
> Below I include a simplification of the situation, page A is the view
> for a particular function in a controller and page B is the script
> that uses JpGraph to generate a particular graphic.
>
> Page A
>    - The relevant data is saved into a session variable.
>    - I call the script embeded in a IMG tag
>
>                 if(!isset($_SESSION))
>                         {session_start();}
>                  $_SESSION['x_series'] = $myData;
>
>             ....
>
>      <img src="<?php echo $this->webroot.'graphics/population.php;?>">
>
> Page B
>    - Copy the session variable to another one.
>    - Process array with data.
>    - Generate graphic
>    - Call stroke function
>
>               ...
>
>               $x_data = $_SESSION['x_series'];
>               foreach ($x_data as $field)
>                   {
>                         array_push($newArray , array_merge($field['0'],
> $field['population_totals']));
>                   }
>
>               foreach($newArray as $element)
>                   {
>                    array_push($period,$element['period'] );
>                    array_push($population,$element['population']);
>                  }
>
>         // Create the graph. These two calls are always required
>         $graph = new Graph(300,200,"auto");
>         $graph->img->SetMargin(40,20,20,40);
>
>           ...
>
> It is in the first foreach where where I get the following error:
> "Invalid argument supplied for foreach", I got the message from the
> web server log. Anyway, It's like the variable is getting there empty.
>
> Any suggestions?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to