Page 1 of 1

A better way than sessions?

Posted: Sun Jul 02, 2006 10:07 pm
by jeeep
After having binged on sessions I've noticed that (for example) the files have to be opened to create the cookies inwhich it will recieve. I'm in the process of making a stats page and I'm using imagecreatefrompng, so if file1.php is viewed without opening file2.php nothing will be seen in file1.php. Sessions works with this but it seems kind of pointless. Is there a way to retrieve a variable from another folder within the server (for example $wins; in public_html/folder1/folder2/score.php from public_html/folder1/something.php) other than sessions?

Posted: Mon Jul 03, 2006 12:47 am
by jmut
it is kind of hard to understand what you mean. maybe the design is messed up. usually things are simple.
could you, please, explain that in other words?

Posted: Mon Jul 03, 2006 1:06 am
by RobertGonzalez
Is this is as simple as using includes?

Posted: Mon Jul 03, 2006 3:42 pm
by jeeep
I believe so, I did some research on it and every test I ran on it the included page poped up and not the string that I wanted from it.
This is a section of what I have:

Code: Select all

include '/vwar/war.php?wins=numwon'; 
   $wins = $numwon;
 include 'war.php';
    header("Content-type: image/png");
    $bg = "/home/uaxtrem/public_html/teamspeakimg.png";
    $im = @ImageCreateFromPNG($bg);;
    $black = imagecolorallocate($im, 255, 255, 255); 
ImageString($im, 3, 148, 50, $wins , $black);
Is there a way to only include the string I need from this file and not the file itself?

Posted: Mon Jul 03, 2006 3:49 pm
by Christopher
Which file? war.php or teamspeakimg.png

Posted: Mon Jul 03, 2006 6:07 pm
by dull1554
your probably better off making a global include with a bunch of predefined variables and then including that file on any page u would need any of those variables

Posted: Tue Jul 04, 2006 1:34 am
by jeeep
Ok that sounds good. I've been trying to make this work but I cant seem to get it right. Here is what I have:

File 1; modules/vwar/war.php -> where the original variable is ($wins), along with other php code

Code: Select all

if ($ownscoretotal < $oppscoretotal)
			{
				$numlost++;
			}
			else if ($ownscoretotal > $oppscoretotal)
			{
				$numwon++;
$wins=$numwon;
			}
			else if ($ownscoretotal == $oppscoretotal)
			{
				$numdraw++;
			}

			unset($ownscoretotal);
			unset($oppscoretotal);
		}
		$vwardb->free_result($result);
File 2; public_html/varwins.php-> intermediate page to store variable $wins

Code: Select all

<?php
include("/public_html/nuke/modules/vwar/war.php");

global $wins;

?>
File 3; public_html/vwin.php -> Recieves variable from file 2 and displays as a png

Code: Select all

<?php
header("Content-type: image/png");
    $bg = "/public_html/teamspeakimg.png";
    $im = @ImageCreateFromPNG($bg);;
    $black = imagecolorallocate($im, 255, 255, 255);
include '/public_html/varwins.php'; 
  
   
    display_data();
 
function display_data()
{
    ImageString($im, 3, 148, 50, $GLOBALS["wins"], $black);
}
     

Imagepng($im);
ImageDestroy ($im);

?>
What of this looks wrong? Also, is having a file in the modules section going to be a problem since you cant open a file from there server side?

Posted: Tue Jul 04, 2006 2:55 pm
by jeeep
Also, is display_data(); only for text files?