torrobinson Posted January 25, 2008 Share Posted January 25, 2008 Hi. I've started looking into PHP.....just today. I'm interested in using it with the game Second Life. So far, I've managed to have chat from Second Life be picked up by a listening object, sent to a php file, and turned into a txt file. Then I have the text file reverse it's lines and show up on a webpage. Above this chatlog, I want to have a square image generated with the gd library that displays the detected "sim" (think of it like a server) and the location (the x, y, z within that server). I am able to get the square drawn and the text "X: Y: Z: SIM:" to appear, but there's no information. Here's what I've got for the location info: <?php $info = $_GET['info']; //gives "13|216|611|Xappen" list($x, $y, $z, $sim) = split('|',$info); //x=13 , y=216, z=611, sim=Xappen $map = ImageCreate (256, 256) or die ("Cannot Create image"); $bg_color = ImageColorAllocate ($map, 20, 20, 20); //greyish $txt_color = ImageColorAllocate ($map, 255, 255, 255); //white text ImageString ($map, 3, 5, 5, "X: " .$x, $txt_color); ImageString ($map, 3, 5, 20, "Y: " .$y, $txt_color); ImageString ($map, 3, 5, 35, "Z: " .$z, $txt_color); ImageString ($map, 3, 5, 50, "Sim: " .$sim, $txt_color); header ("Content-type: image/png"); imagepng($map); ?> Now I KNOW for a fact that the script is getting the info. Because when I added the command to write it to a text file, it added "13|216|611|Xappen" just fine. It just won't "echo" it (when I tried), nor draw it on the image. Help appreciated...I'm completely new to this and probably frustrated over some stupid mistake... Here's where the work in progress is: http://torrobinson.3host.biz/sllog.html Quote Link to comment https://forums.phpfreaks.com/topic/87723-solved-help-for-a-newb-drawing-a-string-with-gd/ Share on other sites More sharing options...
PHP Monkeh Posted January 25, 2008 Share Posted January 25, 2008 Have you tried echo-ing your $x $y $z and $sim strings, just to make sure they're actually getting set a value. Do this before your ImageString() Quote Link to comment https://forums.phpfreaks.com/topic/87723-solved-help-for-a-newb-drawing-a-string-with-gd/#findComment-448726 Share on other sites More sharing options...
torrobinson Posted January 25, 2008 Author Share Posted January 25, 2008 Have you tried echo-ing your $x $y $z and $sim strings, just to make sure they're actually getting set a value. Do this before your ImageString() Yeah... When i'd echo it with some text like "x is:"... ,just the text would come through and not any x value. I'm posting this from my ipod so cant try anything now... Quote Link to comment https://forums.phpfreaks.com/topic/87723-solved-help-for-a-newb-drawing-a-string-with-gd/#findComment-448731 Share on other sites More sharing options...
torrobinson Posted January 25, 2008 Author Share Posted January 25, 2008 Oh before the image thing....I have tried moving it around but let me try tomorrow.... Why does it have to be after that? Quote Link to comment https://forums.phpfreaks.com/topic/87723-solved-help-for-a-newb-drawing-a-string-with-gd/#findComment-448732 Share on other sites More sharing options...
PHP Monkeh Posted January 25, 2008 Share Posted January 25, 2008 You could try explode rather than split: <?php list($x, $y, $z, $sim) = explode("|", $info); ?> Or instead of using list you could assign them all individually <?php $temp = explode("|", $info); $x = $temp[0]; $y = $temp[1]; $z = $temp[2]; $sim = $temp[3]; ?> Quote Link to comment https://forums.phpfreaks.com/topic/87723-solved-help-for-a-newb-drawing-a-string-with-gd/#findComment-448742 Share on other sites More sharing options...
torrobinson Posted January 25, 2008 Author Share Posted January 25, 2008 Thanks for the reply. I tried both of those, and echoing before the imagestring again but nothing came up. And again I tried replacing the echo with saving it to a txt file and it DID work. It has the string...just won`t do anything but save with it so far... Quote Link to comment https://forums.phpfreaks.com/topic/87723-solved-help-for-a-newb-drawing-a-string-with-gd/#findComment-449281 Share on other sites More sharing options...
PHP Monkeh Posted January 25, 2008 Share Posted January 25, 2008 Which string is it that you're saving to the text file? The $x, $y etc or $info? Quote Link to comment https://forums.phpfreaks.com/topic/87723-solved-help-for-a-newb-drawing-a-string-with-gd/#findComment-449297 Share on other sites More sharing options...
torrobinson Posted January 25, 2008 Author Share Posted January 25, 2008 I tried with x and it worked. I`ll try with the other now. Quote Link to comment https://forums.phpfreaks.com/topic/87723-solved-help-for-a-newb-drawing-a-string-with-gd/#findComment-449307 Share on other sites More sharing options...
torrobinson Posted January 27, 2008 Author Share Posted January 27, 2008 *bump* Still I'm having this problem. Basically I can save the string to a file, but I can't echo it or use it in other functions... Anybody have this before? Quote Link to comment https://forums.phpfreaks.com/topic/87723-solved-help-for-a-newb-drawing-a-string-with-gd/#findComment-450747 Share on other sites More sharing options...
torrobinson Posted January 27, 2008 Author Share Posted January 27, 2008 *bump* Still I'm having this problem. Basically I can save the string to a file, but I can't echo it or use it in other functions... Anybody have this before? Nevermind. For some reason, writing it and having another script read it worked fine. Quote Link to comment https://forums.phpfreaks.com/topic/87723-solved-help-for-a-newb-drawing-a-string-with-gd/#findComment-450750 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.