A better way than sessions?
Moderator: General Moderators
A better way than sessions?
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?
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
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:
Is there a way to only include the string I need from this file and not the file itself?
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);- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
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
File 2; public_html/varwins.php-> intermediate page to store variable $wins
File 3; public_html/vwin.php -> Recieves variable from file 2 and displays as a png
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?
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);Code: Select all
<?php
include("/public_html/nuke/modules/vwar/war.php");
global $wins;
?>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);
?>