Jump to content

Recommended Posts

Hey Freaks,

 

I have created a .php file that creates a line graph.  With variables declared inside that file, it draws the graph but I now need to pass data to it.

 

After an earlier post $_SESSION seemed the way to go, but it doesn't appear to be visible inside that .php file.

 

I use the file thus :

print("<pre style='font-family:verdana;font-size:13'>");
	print_r($_SESSION);
	print("</pre>");
	print("<img src='".BASE."/basefunctions/maxgraphs/linegraphdrawer.php' alt='test'>");

 

and inside the function

foreach ($_SESSION as $sesskey=>$sessval) {
	imagettftext($im, $linefontsize, 0, 200, 50, $black, $font, "TEST ".$sessval);
}

 

which breaks the file because, as far as I can tell, $_SESSION is empty.  :-\

 

As far as I was aware, $_SESSION is variable to all functions called throughout the process... or is the <img> reference bypassing that?

 

If so, how do I make the variable available inside the file?

 

Kurrel.

Link to comment
https://forums.phpfreaks.com/topic/66121-_session-visibility-to-php-file/
Share on other sites

If I include linegraphdrawer.php in index.php the drawer bombs as the headers are redeclared.  The only way I was able to get GD to work was this fashion, and now it seems that it's functionality is compromised by an inability to pass data...

 

Seems a database reference may just be the only way to go, unless there's yet another way to reference the session?

<?PHP


// Preperation {
                session_start();
                ob_start();

First thing in index.php,

 

$_SESSION["data"] = "TEST";
	print("<pre style='font-family:verdana;font-size:13'>");
	print_r($_SESSION);
	print("</pre>");
	print("<img src='".BASE."/basefunctions/maxgraphs/linegraphdrawer.php?test=12' alt='test'>");

 

Is then run, and the pre details the session fully, but the image that is presented on the next line does not have session referenced inside it.

will this work...

print("<img src='".BASE."/basefunctions/maxgraphs/linegraphdrawer.php?test=12' alt='test'>");

 

wat does linegraphdrawer.php return?Have u tried executing d code widout using session variables in linegraphdrawer.php?

mean just 2 check if an image is actually being returned frm linegraphdrawer.php and displayed on index.php.

It all works at the moment, I have hard coded values inside linegraphdrawer.php that I am using to render the image.  It works, and displays the graph using the hard data, but I need to replace that hard data with a variable data set stored in the session.

 

the ?test=12 inside the <img> tag was to check whether _GET worked... it does, the _GET is visible when passed this way.  Still no session, though.

 

With or without the session, the .php renders the image... unless I include linegraphdrawer.php in index.php.  I can then see the session, but am unable to utilize gd to draw the graph, the purpose for which it was created in the first place.

 

Blowing my mind.

Nope, the session is the first thing set in the whole process.

 

The image is drawn when the <img> flag is referenced, without prior work.  The session exists before and after, but I begin to think that since it's referencing linegraphdrawer.php directly it is using it as an external resource, in which the current variables of index.php are not visible.

>:(

 

I have tried to circumvent the problem by putting the variables into a database, only to find that any sql work apparently also breaks gd.

 

What use is a graphic set if it can't be used for anything but 100% static, isolated instances?  Is there ANY way (besides _GETting through the URL) to get variables into this?!

If by this you mean

print("<img src='".BASE."/basefunctions/maxgraphs/linegraphdrawer.php?a=".$_SESSION["blah"]."' alt='test'>");

 

I can only extend it so far... if I'm drawing a graph comparing 6 data sets across a year thats 72 variables before I've even passed the actual graph details.  The string length passable in the URL becomes a problem.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.