SimplePortal

Customization => Custom Coding => Topic started by: Malibuz0r on August 30, 2012, 07:50:45 PM

Title: Custom PHP block help
Post by: Malibuz0r on August 30, 2012, 07:50:45 PM
So this is my code right now:

Code: [Select]
<?php
    
global $memberContext$user_info;

    
loadMemberData($user_info['id']);
    
loadMemberContext($user_info['id'], true);

    
$member_info $memberContext[$user_info['id']];
    echo 
$member_info['name'];

    
$s_query ""// My query (Works fine)
    
$s_result mysql_query($s_query) or die(mysql_error());

    if(
mysql_num_rows($s_result) == 1)
    {
        
$s_info mysql_fetch_assoc($s_result);

        
$kills $row['Kills'];
        
$deaths $row['Deaths'];

        if ((
$kills == 0) && ($deaths != 0)) $ratio "-" $deaths ".00";
        elseif ((
$deaths == 0) && ($kills != 0)) $ratio $kills ".00";
        elseif ((
$deaths == 0) && ($kills == 0)) $ratio "0.00";
        else
        {
            
$ratio $kills $deaths;
            
$ratio round($ratio2);
            
$ratio number_format($ratio2);
        }
        
$status $row['Online'];
        
$lastonl $row['Last Online'];
        
$pname $row['Username'];

        
$string1 "Username:";
        
$string2 "Kills: " $kills;
        
$string3 "Deaths: " $deaths;
        
$string4 "Ratio: " $ratio;
        if (
$status == Yes$string7 "Online Now";
        else if (
$status == No$string7 "Last Online: " $lastonl;

        
header("content-type: image/png");
        
$im       imagecreatefrompng("/Sources/msub.png");
        
$red     imagecolorallocate($im25500);
        
$green imagecolorallocate($im156248101);
        
$white  imagecolorallocate($im255255255);
        
$px2     = (imagesx($im) - strlen($string2) + 45) / 2;

        
imagettftext($im803522$green"/Sources/Fonts/Visitor-TT1--BRK-.ttf"$string1);
        
imagettftext($im809222$white"/Sources/Fonts/Visitor-TT1--BRK-.ttf"$pname);
        
imagettftext($im801555$white"/Sources/Fonts/Visitor-TT1--BRK-.ttf"$string2);
        
imagettftext($im801565$white"/Sources/Fonts/Visitor-TT1--BRK-.ttf"$string3);
        
imagettftext($im801575$white"/Sources/Fonts/Visitor-TT1--BRK-.ttf"$string4);

        if (
$status == Yesimagettftext($im8012075$green"/Sources/Fonts/Visitor-TT1--BRK-.ttf"$string7);
        else if (
$status == Noimagettftext($im8012075$white"/Sources/Fonts/Visitor-TT1--BRK-.ttf"$string7);

        
imagepng($im);
        
imagedestroy($im);
    }
?>

Ok, so my issue is, is that when I hit edit, nothing shows but the icon representing a broken image. I'm guessing it has something to do with the way I'm trying to define where the .png and the .ttf font are located. The .png is located inside "Sources", the .ttf font is located in another folder inside sources: "Sources/Fonts".

If I'm wrong, then could someone point out any errors you see up there? Thanks.
Title: Re: Custom PHP block help
Post by: deansmar on August 31, 2012, 01:07:28 AM
the main error that i see straight away it...

you say that this code is being put into a PHP Block in SP.. yes..??

then you don't need the first and last line; "<?php" and "?>" as these are part of the PHP block...
SimplePortal 2.3.8 © 2008-2024, SimplePortal