Hi i have some variables in one file - index.php looking like this:

$kPoln = floor(($getPoln*255)/$max);
$kPolnW = floor(($PolnW*255)/$max);
$kWsch = floor(($getWsch*255)/$max);
$kPoldW = floor(($PoldW*255)/$max);
$kPold = floor(($getPold*255)/$max);
$kPoldZ = floor(($PoldZ*255)/$max);
$kZach = floor(($getZach*255)/$max);
$kPolnZ = floor(($PolnZ*255)/$max);

and i want to send them to another file - image.php - it will serve as colors on some image, and that image will be displayed on index.php, how to do this??

Recommended Answers

All 20 Replies

include 'index.php';//will try to include, will continue if cant find
include_once 'index.php';//will only include it once, will continue if cant find (wont include the same file if it is called more than once)

require 'index.php';//tries to include, fatal error thrown if fails script will not run
require_once 'index.php';//tries to include once, fatal error thrown if fails script will not run (wont include the same file if it is called more than once)

it show only datastrem erorr i mean somthing like this:

<form action="index.php" method="post">
<label for="datefrom">From:</label>
<input type="date" id='datefrom' name="datefrom" />
<label for="dateto">To:</label>
<input type="date" id='dateto' name="dateto" />
<input type="submit" name="submit" id="submit" value="Get Entries" />
</form>


‰PNG



IHDR&&č¬ÖtIDATxśíÝK–ăƵ†Q¦–Fä1]5ěŮ
ÍÉSâm@¦Xŕ"~Äcďĺ†\%•RĚd|<‡HäĎőz˝Đ°ź?
ü!×?ü!ý~öŔĺň¶+˙ţÇJüů˙|ő[jÄürňS¤+űüëżë‰P‰ä$¬sb`¶XEH€R$§–űĚ4Ţ÷î$?Ŕ’SŇ0™yE~€#$ç¨á3óŠüß’śťnĄ™*3ŻÜňŁ=Ŕ’óĄyO{€7$gĄů–öŹ$çĄiߤ)K{€ÉyÎXS
€…ä¬-±YNĆĺŻUçĄ7·ŇÜ?ĽŔlÜcíoNĂ€ű–{¨a6¦śËĺí    hĐ9b5â¬Ěfö)Ç©w"ĚfŢä8é!<0ŹkßžnvkűĽßŞ=%<0¶ą¦'ZăL<0¶Y¦ś§Aç[;FśáńŚ?ĺ8ą:eâńžśź?śV}»…Çç0ěb­ř«c»µíŽoŐw`N9Φ!ŮłÁF›rŞn`:[ÔqVěŮ SăL9^˙Îăú§O7tiäxŮ;—@Źş_¬…_íÚ­˝ŘŞ­w #}O9^äbÜŽüvö°źS†›Ű»;@Ëş\¬ť»K±[{%żU[±dĆő·X3ÜđŠ%4®łĹZ§Éň,Żčą9}Äą±dfő”śzCTÚÔÇbÍŽžoůvQhP—´9ܸŕ^;[µGm~ýŔśZ_¬9/8Č’
ÚŃtrZnZqŞŤh79-÷†î¨´ Ńäč
Ĺ©ś®ąËúşĘČEíoŐVúúÁ´u‘´á†ÚܡNÔĐb­ÇS`ň‹şqn,Ůŕ­$§ÇŢĐ5ŐĽ&’Ł7śBu ěüäôŢ›iwkýnŐî©$ťśśŢ{ĂTbÎLÎ0˝™pĐcÄąQČ8-9Ăô†1¨ś˙^“8'9ăŤ8SíÖŰŞÝt ¶’3^o†ę@UéäÜ›IťQGśŐz˘É¸7ŚDu ’\rô†Ž¨ÔJÎ$˝~·6üVížę@q.’ $‘śIFĆcвŞ'g¶ŢĽ[›j«vŁ:PPÝäĚÖ†¤:PJĹäLŰ›!ť9GśŐ"\>@H­äL;â0*W%9z3Řnmň­ÚŤęŔAĺ“Ł7LuŕďĺÔ2Ě cÄJ)ś#Ă3čŔn%“Ł7LBu`‹µŠŘ­ŮŞKŽ‡©t`‡2ÉŃ›WştŚ8ď©|Ëb
€É1â0-|Ĺ”S]§»5[5 ¸ŁÉ1â09lw(9złQwŽç+ŞY¬˛?9F¸1čŔ¦śŽvk¶j@%;“cÄ|dĘÉébĐ1âőěIŽž2čŔ{¦BľNŽçĆwk¶jÇtŕ
S!ß%ÇtŕSNZł»5[5 ¶/’cÄŤ:đ”)ç
:F `krŚ8đ<2ĺ˛)9FśâšÚ­ŮŞUbĐS!ź“cÄ©¤‘AÇS•Aî}HŽgçy‹ß·üMËĆařŠŇŔĘçĹÚ­4?üő?J9}·f«VĂę™âá…›MSÎňśą=…=đÔę™ç¬ü\Ż×—ż÷âÂĎ«˛–Çóß˙řOřßkÄ)eË3Âe8pŮ8ĺ¬zŕňě­ĎxoOr÷ďń\.6×LÄ űĽ\¬}»đŠďünÍVm‡Ą±[ýSÎĘjčąX¸1c
QlĘyú'Üó,}/9čq6*ű5lĘçSN‘熫čWŤLËÍo<Y±ĹÚ+®2 #Fs¨*w'éëźż<ÝČ`%v'[µ§V_«/W 'SNŐŮßĐCSÂcŤÝ“;íçĺz#ÎŤ±ňŞż—󞡇0ďÖŔ‰NNÎŤËۨʷ*CÖß—ÓȢyć—˘őľAgέZ_KŤ<Ë Ż•)gĺéĐsiăĽ
–h497Ńa±f5şX{e’Ó¤Ćnmř­ZG_Ť?Ë ž_¦śöź ®2ŕQG±Yřî¦őË”ÓÝÓ »łf»˛Î#NןýîžkPDÓďĺ|dč™S×±™őťś…ď'ť„Ň@ďţ^¬
3és0•Ú­
°Ućszogl7”łbčĆĄ™
8ĺ¬t}ltzq&ą9ͨĎ8xcŔ)gĹĐÓ‘®_Ťźś7Ńi–ŇŔ$ţZ¬M8ă÷rĚŮ­µżUëĺłPÉ„Ď;&7Ń”łbáv˘ÉKÓ:í§‚¶ŁńźOşűG…¶9âřYś0ły§śCOUĆŕ"9ŹÜD§,±nć˝|`ŁFNĚo/"8}«ÖČăÖ8Ď;fóűĹ×ý[†žo‰Ív~Šłůą^Żľč·;ń<Ý>čś2â(Í>ž}LĹ{9ß1ô¬Lrs ÉŮĂĺmc
đ=‹µbŻô·ěÖjoŐ”¦,Ď>¦bĘ)`5ô\]¸‰
p)§Šz§óűA§ĆŁ4Uyö1SNc\e 6@Y’SQ§W(
PÉĎĺ˙®Î”ŚRGů«ÝÚń­šŘśÂnŤyrršz”Čś´óNŹŘIkçŰqî?îÖľÚŞ)MS,Ö‡)ç|±ˇÇÍi€s™ršłqąt>Ž8Ćš–™r‡)§9O‡žË®N(
ĐÉiÔÁ›č
Đ ‹µn<VäţWVłŃý/Ň8‹5ćaĘéĆ«…ŰÓ˙ë$9ťy\¸=ý]€ývöŔ,L9ťy5Ü´v€G¦śnüüńäzŰo]˙\˙ĘÓ8śČ”ÓşŻ®höΡÉiÖÇ›ÓÜ›Î2ÓÜ˙
íÜ9ŕFršSđrgCĐÉiEŐo¬)x€ÝÜ}ŕ|»xÁęzŤ˙ěľ#ő¸űó0ĺśćÄsßÂ
8…)çcój Ů}Ť€ˇç\¦ćaĘÉiöd7ô’“ĐllV\Z
Tős˝^Íő•Ô(Íű”ŤD/ĄěšgS1ĺT1ĆamčĘ’ś’j—ć㡿ÜßłěgďôĄHNoN3Cpä2Ćí+†`7ÉŮă”Ňlś*jěÖ^ý‹.CĎE{€×$ç;Ž5ď=ţ`l7ŕÉŮDi>˛p>ňSA?xüYś§śˇ_Ť«•WźO
ĽňűĺŰŻFďk2ôláyÇlL9kŤŚ5÷vĽ;rî sĎĐÜx/ç/ĆšŞ=ŔEr.b“ĺűIafó&§—Ňě>”cß łˇć4]r&ą9M/=0•źëőú×_5ůr¸ ^Ćš{ÇŹŕľń?G»
˙ŚGăO9Sťb˝sŰČÉ›Ną‰ŚjŔäSš"çlË|ä*ĚPÉ&6¬¸ĘĆđ÷ĺ—nßϲ4eOŐÁÎč>ăť>×ŕ ľ§śŽv0ô@§şLŽŇpńNt¨łŰz6xĎÍŠżloç.ź5¸s(ôâ—)§Ůźb`¬áŁŽ†ž6źeĐôbmΛÓTzg˘ë«ĄżâťhVŁÉ1ÖpPGCĚŁ­ä(
Ĺą‰´ă—ďËůë—Îؽ͢öČ–éôŻ´v›đĘÉSÎéĎfcá':í"éI.wţJ`űj鯸´ňŇSŽ±†¦z éIr*}wŽŘв̥ŐŢČarŐ§ĄŮ(öĆţ<ß łˇŞŞ±ˇ_ľźjxžś#»5Ąae‡“%›rćĽ9M)áŃvkß2ô@’c¬aŢéžÜ}ŕďß{ű*XiJ9ë%ł—ę}5Ů›)á˛oʸ<=‡OľHŽŇŔSn°Ń»ĹÚĺ۱©çÜ×Ĺ^•×đř|±UĹç)ÇK6řĘ«ˇŘt[O÷ܬäô!Ă]>«ňÄ•Éń„ă<Ź`qÚ/`6ź“óxůEśľU[Ř­Uĺ¸gĘ dëĺ^—ŐČł0čTbÄS![“cĐŻqŕ‘)çMmŐvk@ŔÉ1čŔFFxĘ”“Öŕł0čµ}—|dÄWL9„|ťÎÍnŐvkÇqŕ
S!{’cĐ٧ńgaĐ9Âď™rŮ™¬qŕ#SNH[µ…ÝPÉţätŕĆ[r9”ÎFmŐvk_1âŔFG§ŐarzŰY¬U×Ýł0čĹHŽA‡iqŕ+¦BĘ$Ç óJ§[µ…ÝÚ{FřV±)GuŠŢŔku=â,:@A%“cĐaFاđ”Ł:Oo`7‹µZŘŞ-ěÖ€RĘ'Ç ĂŔŚ8pD•)Gu†qť…ŢŔAµkŞĂ`ôŽó^!“3í 3ŘVm1ůnÍEÔťr¦­#Ń(Ąúbm¶ę9â,ćtô
JĽ—3[u†Ţ@Y. $”śIť·j‹©vkF(.7ĺLRĆ 7PCt±6vu†q3:z•¤ßË»:@o ž.PšĄ7PŐ9W¬ŤWťI¶j‹QwkzµąH€Ó’3Ţ C׌8pć”3Lu¦ÚŞ-Ű­é
dśĽX¦:ôKo ćü÷rzŻÎ„#ÎbŚAGo éüä\úŻťŇk"9Ő!No Ż•ä\ú¬Î´[µEż»5˝Sü~öđ‹[uTâNôs˝^ĎţžčâE¨ĂkŃŃăĐĹ׬ˇĹÚ˝—l4NoŕtŤ&ç˘:Ą7Đ‚v“si»:m“jk˙"˝F4ťśKŰŐˇzíhôň•ÖFŠÖ>ž4ř4ř!ÁäÚşHú•ŰęĆńÁFľZ A­/ÖîY˛±‘Ţ@›zJÎĄŤęX×<ŐÎEzÍęc±vĎ
xĹ4®ŹËž:ĺŬCí˝Ă
´ŻłĹÚ˝–l4Bo ý-ÖîY˛á:Ňńbí^ćE®Óm‹äŁd¸ľô=ĺÜwfăÓ
=dĘą©÷˛×·]íÇĘpťdĘą1îŚÍ'ş6Zr.ż~O˘łi>ˇ0€Ńk+Ą60λo•}ÄlŇ`N9÷ěŮzçÓ#<9{¶nů”Áx_¬­ě;Ĺś}űě~Ü<ŕ0Şń§ś{&žĆůÔŔŘćšrîm<Ý‚Glô<Î0ą¦ś{&žFřŔ<ćMÎBxNäa‡ŮĚ»X{ôx:Ź{úz`aNłO9÷L<^™)çąŰs8w˙“ô<ž03ÉyÉAY„x7’ł‰só[1ŕ‘ä|ÇIúžÇxCrvr¶Ţóh[HÎQÓľĺ3í8°›ä”4ü)<ü P•äÔ2Ěé<Ěp:ÉI¸?µ/ÍÜ}}´@G$ç«3ýrę±ŢÔŚMršđxîß  @í?`ÉiÝ›Zl§+@$€ßÎţ…ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!’@ä"9„H!˙Ôâoůžü^ŮIEND®B`‚Treść komunikatu gdy $t=0

    </body>

you should make a variables file like inc.php

which contains the variables the pages will share, index.php sounds like a page that will have lots going on in it so isn't a good idea to include into another

inc.php
<?php
$colours = array(0=>'#ff8888',1=>'#88ff88',2=>'#8888ff');
?>
--------------

index.php
<?php
include 'inc.php';

echo $colours[1];
?>
-----------------------------------

image.php
<?php
include 'inc.php';

echo $colours[2];
?>

if its not that you could try doing an include like:
include('inc.php');

otherwise it's going to be a server error such as includes being turned off, you can check by typing:

phpinfo();

into a php file and it will output the current php settings on the server, it will say if includes are allowed or not

i think it has to do something with image png.

Sorry i missed you had updated and replied

are you using imagepng() on the page?

if you are trying to pull and display an image with php you put it into a separate file eg.

image.php
<?php
header('content: image/png');

//do stuff to get image
imagepng($img);
?>
---------------------------
index.php

..html stuff...
<img src='image.php'/>
...html stuff...

imagepng prints out raw image data so if used while displaying html content type you will get that

Still i would need to send variables to that image.php and i dont know how.

Member Avatar for diafol

something like this?

<?php
$getPoln = 200;
$PolnW = 1;
$getWsch = 233;
$PoldW = 10;
$getPold = 189;
$PoldZ = 39;
$getZach = 11;
$PolnZ = 167;

$max = 11;

$params = array(
	'kPoln' => floor(($getPoln*255)/$max),
	'kPolnW' => floor(($PolnW*255)/$max),
	'kWsch' => floor(($getWsch*255)/$max),
	'kPoldW' => floor(($PoldW*255)/$max),
	'kPold' => floor(($getPold*255)/$max),
	'kPoldZ' => floor(($PoldZ*255)/$max),
	'kZach' => floor(($getZach*255)/$max),
	'kPolnZ' => floor(($PolnZ*255)/$max)
);
foreach($params as $k=>$v){
	$p[] = "$k=$v";	
}
$qs = implode('&',$p);


?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlnors="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<img src="image.php?<?php echo $qs;?>" />
</body>
</html>

well i could be something like this i think but how i use them in image.php??

Coz in image.php i have tu use those eight variables to color the circle.

Member Avatar for diafol

The colours are passed to the image.php file in the querystring:

<img src="image.php?kPoln=4636&kPolnW=23&kWsch=5401&kPoldW=231&kPold=4381&kPoldZ=904&kZach=255&kPolnZ=3871" />

yeah i now but in image.php variables must have the same name or i am missing something??

Member Avatar for diafol

The image.php will accept:

$_GET['kPoln']
$_GET['kPolnW']

etc

Well its still nothing so i am thinking that i will show my code in those 2 files and maybe this will be better

co index.php looks like this:

<html>
	<head>
		<title></title>
	</head>
	<body>

<form action="index.php" method="post">
    <label for="datefrom">From:</label>
    <input type="date" id='datefrom' name="datefrom" />
    <label for="dateto">To:</label>
    <input type="date" id='dateto' name="dateto" />
    <input type="submit" name="submit" id="submit" value="Get Entries" />
</form>
<?php
$list = "";
if(isset($_POST['submit']))
{
$datefrom = $_POST['datefrom'];
$dateto = $_POST['dateto'];
 
$datefrom = $datefrom . " 00:00:00";
$dateto = $dateto . " 23:59:59";
 
$lines = file('KierunekW.txt');
foreach($lines as $line){
   	$r = explode(",",$line);
   	if(strtotime($r[0]) >= strtotime($datefrom) && strtotime($r[0]) <= strtotime($dateto))$list .= "\n\t<li>{$r[1]}</li>";
}
if($list !="")$list = "\n<ul>$list\n</ul>";
}// counting occurences of same strings
$getText = $list;
$Poln = substr_count($getText ,"Polnoc");
$PolnW = substr_count($getText ,"Polnocny-Wschod");
$Wsch = substr_count($getText ,"Wschod");
$PoldW = substr_count($getText ,"Poludniowy-Wschod");
$Pold = substr_count($getText ,"Poludnie");
$PoldZ = substr_count($getText ,"Poludniowy-Zachod"); 
$Zach = substr_count($getText ,"Zachod");
$PolnZ = substr_count($getText ,"Polnocny-Zachod");
$getPoln = $Poln - $PolnW - $PolnZ ;
$getPold = $Pold;
$getZach = $Zach - $PoldZ - $PolnZ ;
$getWsch = $Wsch - $PoldW - $PolnW ;
//max this value
$max = max(array($getPoln,$PolnW,$getWsch,$PoldW,$getPold,$PoldZ,$getZach,$PolnZ)); 

if($max!=0 && $getPoln!=0  && $PolnW!=0 && $getWsch!=0 && $PoldW!=0 && $getPold!=0 && $PoldZ!=0 && $getZach!=0 && $PolnZ!=0)
{
// Now i count a color value
$params = array(
	'kPoln' => floor(($getPoln*255)/$max),
	'kPolnW' => floor(($PolnW*255)/$max),
	'kWsch' => floor(($getWsch*255)/$max),
	'kPoldW' => floor(($PoldW*255)/$max),
	'kPold' => floor(($getPold*255)/$max),
	'kPoldZ' => floor(($PoldZ*255)/$max),
	'kZach' => floor(($getZach*255)/$max),
	'kPolnZ' => floor(($PolnZ*255)/$max)
);
foreach($params as $k=>$v){
	$p[] = "$k=$v";	
}
$qs = implode('&',$p);


}else
{
echo 'variable is 0';
}
?>
<img src="image.php?<?php echo $qs;?>" />
	</body>
</html>

and in the image.php it goes like this

<?php

$kPoln = $_GET[ 'kPoln' ]; 
$polb = $_GET[ 'kPolnW' ]; 
$polc = $_GET[ 'kWsch' ];
$pold = $_GET[ 'kPoldW' ];
$pole = $_GET[ 'kPold' ];
$polf = $_GET[ 'kPoldZ' ];
$polg = $_GET[ 'kZach' ];
$polh = $_GET[ 'kPolnZ' ];
// set the HTTP header type to PNG
header("Content-type: image/png"); 
 
// set the width and height of the new image in pixels
$width = 550;
$height = 550;
 
// create a pointer to a new true colour image
$im = ImageCreateTrueColor($width, $height); 
ImageAntiAlias($im, false);
$white = ImageColorAllocate($im, 255, 255, 255); 
ImageFillToBorder($im, 0, 0, $white, $white);


 
//colors
$b = ImageColorAllocate($im, 0, 100, 255);
$t = ImageColorAllocate($im, $pola, $pola, $pola); // i woul like to use variables from index.php here
//next other colors

imagesetthickness($im, 2);
// draw an empty circle
ImageEllipse($im, 150, 150, 300, 300, $b);
//Lines on circle - borders
ImageLine($im, 95, 10, 205, 290, $b);
ImageLine($im, 205, 10, 95, 290, $b);
ImageLine($im, 10, 95, 290, 205, $b);
ImageLine($im, 10, 205, 290, 95, $b);

//filling with color
imagefilltoborder($im, 150, 50, $b, $t);
//next for other filling
ImagePNG($im); 
ImageDestroy($im); 
?>

kind of big post but realy dont know what to do with those variables sending/using

Member Avatar for diafol

You've got them, but you don't use them:

$t = ImageColorAllocate($im, $pola, $pola, $pola);

You're using $pola - which doesn't seem to exist

Right right - its working, my mistake.

I have one more question coz now before i enter the date in fields i have red "x" in a place of where image should be (he dont have variables to draw). Is there a way to not showing for this red x??(maybe in if function)

Member Avatar for diafol

It would be easier to not show the image at all on the index.php page:

<?php
if(...parameters/variables exist...){
   echo "<img src=\"image.php?$qs\" />";
}
?>

OR you could show a default 1x1 transparent gif via the image.php script. However, this would make little sense as a screen reader / view source would tell you that something was there - but you'd be a naughty little thing and would be tellings fibs.

It is working but could it be in div?? i would like to align this on center of page

You can use them from URL as
$_GET
$_GET
etc..

Oki on local server it works fine - i use xampp but on web it show me a red x, what could be wrong??

I could edit my last post but the problem with red x is Call to undefined function: imageantialias() it somthign with GD but i dont know how to fix it

Member Avatar for diafol

Is gd loaded? Are you tunning a really old v of php. See what's available with phpinfo()

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.