posting array to an external php file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ben

    posting array to an external php file

    Hi,

    I do use JPGraph for ploting some data.

    I compute the data and generate to sets of DATA.

    $X and $Y.

    I have also written a plot.php file where run my plot.

    What I want to do is something like below?

    Dos anyone know it is possible? Cause I cannot post the Array values.

    <img src=plot.php?X= $X&Y=$Y>

    The plot.php sends the header as a PNG file and generate the plot.

    Regards...

  • Ben

    #2
    Re: posting array to an external php file

    BTW

    When I do it like that it works. But sometimes array is long as 15000
    numbers. So this would not be a clever idea.

    I SEND
    ---------------------
    print"<img src=\"plot_pdf. php?
    Y=".urlencode(s erialize($Y))." &
    X=".urlencode(s erialize($X))." \">";

    I GET
    -------------
    $X = unserialize($_G ET['X']);
    $Y = unserialize($_G ET['Y']);

    Comment

    • luke

      #3
      Re: posting array to an external php file

      This could be a really bad suggestion, but, could your script quickly write
      the array to a .txt file which is read by the next website.



      "Ben" <ben@ventusvigo r.com> wrote in message
      news:1122226960 .414627.9040@g4 9g2000cwa.googl egroups.com...[color=blue]
      > Hi,
      >
      > I do use JPGraph for ploting some data.
      >
      > I compute the data and generate to sets of DATA.
      >
      > $X and $Y.
      >
      > I have also written a plot.php file where run my plot.
      >
      > What I want to do is something like below?
      >
      > Dos anyone know it is possible? Cause I cannot post the Array values.
      >
      > <img src=plot.php?X= $X&Y=$Y>
      >
      > The plot.php sends the header as a PNG file and generate the plot.
      >
      > Regards...
      >[/color]


      Comment

      • Michael Phipps

        #4
        Re: posting array to an external php file


        "luke" <lduncalfe@eml. nope> wrote in message
        news:XGTEe.3140 $PL5.308308@new s.xtra.co.nz...[color=blue]
        > This could be a really bad suggestion, but, could your script quickly
        > write
        > the array to a .txt file which is read by the next website.[/color]

        That's not a bad idea - and to get around the problem of the wrong data
        going to the wrong viewer, perhaps using a random file name could help? PHP
        has a function for creating a temp filename called "tempnam"

        If the page that generates the img tag is php page that first generates the
        data to be ploted, you could make your img tag something like:
        <img src="plot.php?T MPA092e45xf" />

        When plot displays the the file, at the end it could delete the temporary
        file...


        Comment

        • NC

          #5
          Re: posting array to an external php file

          Ben wrote:[color=blue]
          >
          > I do use JPGraph for ploting some data.
          > I compute the data and generate to sets of DATA.
          > $X and $Y.
          > I have also written a plot.php file where run my plot.
          > What I want to do is something like below?
          >
          > Dos anyone know it is possible? Cause I cannot post the Array values.
          >
          > <img src=plot.php?X= $X&Y=$Y>
          > The plot.php sends the header as a PNG file and generate the plot.[/color]

          There are several possible solutions to your problem:

          1. Move the computation from its current location into plot.php
          and pass to plot.php only the inputs necessary to make the
          computation. This will have the best results if you don't
          need to display the results of the computation in the HTML
          you generate.

          2. Record $X and $Y into a randomly-named text file, pass its
          name to plot.php and make plot.php delete it after it has
          read and verified the data.

          3. Record $X and $Y into session variables.

          Cheers,
          NC

          Comment

          • Ken Robinson

            #6
            Re: posting array to an external php file



            NC wrote (in part):[color=blue]
            > 2. Record $X and $Y into a randomly-named text file, pass its
            > name to plot.php and make plot.php delete it after it has
            > read and verified the data.
            >
            > 3. Record $X and $Y into session variables.[/color]

            Number 3 is the best option.

            If you want to use a file, I suggest you look at the function tmpname()
            <http://www.php.net/tmpname>. Then you can either pass the name on the
            URL or use a session varible to pass the name.

            Ken

            Comment

            • R. Rajesh Jeba Anbiah

              #7
              Re: posting array to an external php file

              Ben wrote:
              <snip>[color=blue]
              > What I want to do is something like below?
              >
              > Dos anyone know it is possible? Cause I cannot post the Array values.
              >
              > <img src=plot.php?X= $X&Y=$Y>[/color]

              FWIW, You may also pass the array via query string:
              1. <img src="plot.php?X[]=1&Y[]=2&X[]=2&Y[]=4" />
              2. <img src="plot.php?X[10]=1&Y[10]=2&X[4]=2&Y[4]=4" />

              --
              <?php echo 'Just another PHP saint'; ?>
              Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com

              Comment

              • luke

                #8
                Re: posting array to an external php file


                Yes .. nice solution. I was thinking mainly about the problem with what do
                with with the .txt file once it's been used. But that deletion would be very
                nice. Another, slightly shitting way, could be a PHP script activated by a
                cron job that purges files older than, say, and hour, that runs once a day
                or so. ?



                "Michael Phipps" <gravityspike_s pamfree_@optusn et.com.au> wrote in message
                news:42e42016$0 $27877$afc38c87 @news.optusnet. com.au...[color=blue]
                >
                > "luke" <lduncalfe@eml. nope> wrote in message
                > news:XGTEe.3140 $PL5.308308@new s.xtra.co.nz...[color=green]
                > > This could be a really bad suggestion, but, could your script quickly
                > > write
                > > the array to a .txt file which is read by the next website.[/color]
                >
                > That's not a bad idea - and to get around the problem of the wrong data
                > going to the wrong viewer, perhaps using a random file name could help?[/color]
                PHP[color=blue]
                > has a function for creating a temp filename called "tempnam"
                >
                > If the page that generates the img tag is php page that first generates[/color]
                the[color=blue]
                > data to be ploted, you could make your img tag something like:
                > <img src="plot.php?T MPA092e45xf" />
                >
                > When plot displays the the file, at the end it could delete the temporary
                > file...
                >
                >[/color]


                Comment

                Working...