What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » PHP Images... I can't make one. :(

Pages: (4): « First « 1 2 [ 3 ] 4 » Last »
PHP Images... I can't make one. :(
Author: Message:
Moo
Full Member
***

Avatar

Posts: 395
Reputation: 19
Joined: Jun 2004
O.P. RE: PHP Images... I can't make one. :(
Sweet! I have numbers!
ill just make a background and align the numbers.
01-21-2005 09:38 PM
Profile E-Mail PM Find Quote Report
Moo
Full Member
***

Avatar

Posts: 395
Reputation: 19
Joined: Jun 2004
O.P. RE: PHP Images... I can't make one. :(
:/
code:
<?
$handle = fopen("http://www.bungie.net/Stats/PlayerStats.aspx?player=guyguyme2003", "rb");
$contents = '';
while (!feof($handle)) {
$contents .= fread($handle, 8192);
}
fclose($handle);



$match = InsideTags('<div class="ExpBar" style="width:50"><div class="ExpBarText" style="left:20">','</div></div>',$contents); // uses a regular expression and gets the stuff inbetween those two points and returns it


$rumble_pit = $match[1][0];
$team_skirmish = $match[1][1];
$head_to_head = $match[1][2];
$big_team_battle = $match[1][3];
$team_slayer = $match[1][4];


function InsideTags($tag1,$tag2,$html){ //function to grab text inbetween two points
$tag2 = str_replace('/', "\/" ,$tag2);
preg_match_all("/$tag1(.*)$tag2/i", $html, $match);
return $match;
}


header("Content-type: image/png");
$im = @imagecreatefrompng("http://guillaumelforum.theglassprison.net/Halo%202%20Stats_files/stats1.png");
$text_color = imagecolorallocate($im, 0, 0, 0);
$line = 10;
imagestring($im, 12, 5, $line, $rumble_pit, $text_color);
$line = $line + 15;
imagestring($im, 12, 5, $line, $team_skirmish, $text_color);
$line = $line + 15;
imagestring($im, 12, 5, $line, $head_to_head, $text_color);
$line = $line + 15;
imagestring($im, 12, 5, $line, $big_team_battle, $text_color);
$line = $line + 15;
imagestring($im, 12, 5, $line, $team_slayer, $text_color);

imagepng($im);
imagedestroy($im);

?>

gave me
quote:
Originally posted by Error
<br />
<b>Warning</b>:  imagecolorallocate(): supplied argument is not a valid Image resource in <b>/home/theglas/public_html/guillaumelforum/halo2/index.php</b> on line <b>30</b><br />
<br />
<b>Warning</b>:  imagestring(): supplied argument is not a valid Image resource in <b>/home/theglas/public_html/guillaumelforum/halo2/index.php</b> on line <b>32</b><br />
<br />
<b>Warning</b>:  imagestring(): supplied argument is not a valid Image resource in <b>/home/theglas/public_html/guillaumelforum/halo2/index.php</b> on line <b>34</b><br />
<br />
<b>Warning</b>:  imagestring(): supplied argument is not a valid Image resource in <b>/home/theglas/public_html/guillaumelforum/halo2/index.php</b> on line <b>36</b><br />
<br />
<b>Warning</b>:  imagestring(): supplied argument is not a valid Image resource in <b>/home/theglas/public_html/guillaumelforum/halo2/index.php</b> on line <b>38</b><br />
<br />
<b>Warning</b>:  imagestring(): supplied argument is not a valid Image resource in <b>/home/theglas/public_html/guillaumelforum/halo2/index.php</b> on line <b>40</b><br />
<br />
<b>Warning</b>:  imagepng(): supplied argument is not a valid Image resource in <b>/home/theglas/public_html/guillaumelforum/halo2/index.php</b> on line <b>42</b><br />
<br />
<b>Warning</b>:  imagedestroy(): supplied argument is not a valid Image resource in <b>/home/theglas/public_html/guillaumelforum/halo2/index.php</b> on line <b>43</b><br />


01-21-2005 09:56 PM
Profile E-Mail PM Find Quote Report
WDZ
Former Admin
*****

Avatar

Posts: 7106
Reputation: 107
– / Male / Flag
Joined: Mar 2002
RE: PHP Images... I can't make one. :(
Well, the URL http://guillaumelforum.theglassprison.net/Halo%20...s_files/stats1.png doesn't work for me, and it's not necessary to use a URL anyway. You should have the image on the same server as the script and use a relative path, such as "Halo 2 Stats_files/stats1.png" or just "stats1.png" if the image and script are in the same folder.
01-21-2005 10:01 PM
Profile PM Web Find Quote Report
Moo
Full Member
***

Avatar

Posts: 395
Reputation: 19
Joined: Jun 2004
O.P. RE: PHP Images... I can't make one. :(
oops.. wrong url... wrong format... :* http://guillaumelforum.theglassprison.net/halo2/H...s_files/stats1.jpg
01-21-2005 10:05 PM
Profile E-Mail PM Find Quote Report
Moo
Full Member
***

Avatar

Posts: 395
Reputation: 19
Joined: Jun 2004
O.P. RE: PHP Images... I can't make one. :(
Why wont this work?
code:
<?
$handle = fopen("http://www.bungie.net/Stats/PlayerStats.aspx?player=guyguyme2003", "rb");
$contents = '';
while (!feof($handle)) {
$contents .= fread($handle, 8192);
}
fclose($handle);



$match = InsideTags('<div class="ExpBar" style="width:50"><div class="ExpBarText" style="left:20">','</div></div>',$contents); // uses a regular expression and gets the stuff inbetween those two points and returns it


$rumble_pit = $match[1][0];
$team_skirmish = $match[1][1];
$head_to_head = $match[1][2];
$big_team_battle = $match[1][3];
$team_slayer = $match[1][4];


function InsideTags($tag1,$tag2,$html){ //function to grab text inbetween two points
$tag2 = str_replace('/', "\/" ,$tag2);
preg_match_all("/$tag1(.*)$tag2/i", $html, $match);
return $match;
}


header("Content-type: image/png");
$im = @imagecreatefromjpg("http://guillaumelforum.theglassprison.net/halo2/Halo%202%20Stats_files/stats1.jpg");
$text_color = imagecolorallocate($im, 0, 0, 0);
$line = 10;
imagestring($im, 12, 5, $line, $rumble_pit, $text_color);
$line = $line + 15;
imagestring($im, 12, 5, $line, $team_skirmish, $text_color);
$line = $line + 15;
imagestring($im, 12, 5, $line, $head_to_head, $text_color);
$line = $line + 15;
imagestring($im, 12, 5, $line, $big_team_battle, $text_color);
$line = $line + 15;
imagestring($im, 12, 5, $line, $team_slayer, $text_color);

imagepng($im);
imagedestroy($im);

?>

01-21-2005 10:07 PM
Profile E-Mail PM Find Quote Report
WDZ
Former Admin
*****

Avatar

Posts: 7106
Reputation: 107
– / Male / Flag
Joined: Mar 2002
RE: PHP Images... I can't make one. :(
imagecreatefromjpg should be imagecreatefromjpeg (add an e)

Also, your text color should be white (255,255,255) instead of black since your background is dark.

The script works fine for me after those 2 changes. Needs some tweaking, but at least it's working...
01-21-2005 10:12 PM
Profile PM Web Find Quote Report
Moo
Full Member
***

Avatar

Posts: 395
Reputation: 19
Joined: Jun 2004
O.P. RE: PHP Images... I can't make one. :(
quote:
Originally posted by WDZ
imagecreatefromjpg should be imagecreatefromjpeg (add an e)

Also, your text color should be white (255,255,255) instead of black since your background is dark.

The script works fine for me after those 2 changes. Needs some tweaking, but at least it's working...
Sweet
* Moo fixes
01-21-2005 10:13 PM
Profile E-Mail PM Find Quote Report
Moo
Full Member
***

Avatar

Posts: 395
Reputation: 19
Joined: Jun 2004
O.P. RE: PHP Images... I can't make one. :(
using
code:
<?
$handle = fopen("http://www.bungie.net/Stats/PlayerStats.aspx?player=guyguyme2003", "rb");
$contents = '';
while (!feof($handle)) {
$contents .= fread($handle, 8192);
}
fclose($handle);



$match = InsideTags('<div class="ExpBar" style="width:50"><div class="ExpBarText" style="left:20">','</div></div>',$contents); // uses a regular expression and gets the stuff inbetween those two points and returns it


$rumble_pit = $match[1][0];
$team_skirmish = $match[1][1];
$head_to_head = $match[1][2];
$big_team_battle = $match[1][3];
$team_slayer = $match[1][4];


function InsideTags($tag1,$tag2,$html){ //function to grab text inbetween two points
$tag2 = str_replace('/', "\/" ,$tag2);
preg_match_all("/$tag1(.*)$tag2/i", $html, $match);
return $match;
}


header("Content-type: image/png");
$im = @imagecreatefromjpeg("http://guillaumelforum.theglassprison.net/halo2/Halo%202%20Stats_files/statsforimg.jpg");
$text_color = imagecolorallocate($im, 255, 255, 255);
$line = 42;
imagestring($im, 1, 102, $line, $rumble_pit, $text_color);
$line = $line + 10;
imagestring($im, 1, 102, $line, $team_skirmish, $text_color);
$line = $line + 10;
imagestring($im, 1, 102, $line, $head_to_head, $text_color);
$line = $line + 10;
imagestring($im, 1, 102, $line, $big_team_battle, $text_color);
$line = $line + 10;
imagestring($im, 1, 102, $line, $team_slayer, $text_color);
imagepng($im);
imagedestroy($im);

?>

I only get 3 values :s
[Image: index.php]
01-21-2005 10:43 PM
Profile E-Mail PM Find Quote Report
WDZ
Former Admin
*****

Avatar

Posts: 7106
Reputation: 107
– / Male / Flag
Joined: Mar 2002
RE: PHP Images... I can't make one. :(
Hmm... it looks like the stats page on bungie.net has changed... :^)

"Head To Head - No Games Played" messes up the script. That sucks... :p

I don't see an easy way to fix the problem... the script would require some changes, and I don't have time to help with that right now.
01-21-2005 10:59 PM
Profile PM Web Find Quote Report
Moo
Full Member
***

Avatar

Posts: 395
Reputation: 19
Joined: Jun 2004
O.P. RE: PHP Images... I can't make one. :(
quote:
Originally posted by WDZ
Hmm... it looks like the stats page on bungie.net has changed... :^)

"Head To Head - No Games Played" messes up the script. That sucks... :p

I don't see an easy way to fix the problem... the script would require some changes, and I don't have time to help with that right now.
I'll try and figure it out.
01-21-2005 11:03 PM
Profile E-Mail PM Find Quote Report
Pages: (4): « First « 1 2 [ 3 ] 4 » Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On