Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[PHP] Little problem, changing text to image

Skilled Illusionist
Joined
Oct 8, 2010
Messages
332
Reaction score
24
Hey RaGEZONER's,

I got a problem, more a suggestion with my PHP stat page.
I don't want that it says online/offline but that a picture will appear.

This script I use atm:
<?php
$srvip = "127.0.0.1"; //Input WanIP
$srvport = "6000"; //Port
$dns="GunzDB";
$user="SA";
$pass="******"; //Input Password Here
$connect=odbc_connect($dns, $user, $pass) or die ("Couldn't connect to the database, we're sorry...");
odbc_exec($connect,"use GunzDB");
?>
<tr>
<td align="right"></td>
<td><?php
$fp = @fsockopen($srvip, $srvport, $errno, $errstr, 1);
if (!$fp) {
echo "<font style='color: #FF3300'><B>Offline</B></font></br>";
} else {
echo "<font style='color: #009933'><B>Online</B></font></br>";
fclose($fp);
} ?></td>
</tr>

The images are located in:
site.com/images/offline.png
site.com/images/online.png

This stat is located in:
site.com/scripts/stats.php

So i think we have to use the:
../images/online.png
code but if I do that, errors appear.

Someone can help me out, I tried this in the first place:

//replaced the offline thing with this
echo "<font style='color: #FF3300'><B><html><head><body><img src="/images/offline.png" alt="" /></body></head></html></B></font></br>";

The official IMG Scr is ../images/offline.png but in spoiler it shows up as forum.ragezone.com/images/offline.png so ye xD

Thanks if you can help me =)

:thumbup:
 
Last edited:
Joined
Sep 10, 2006
Messages
2,817
Reaction score
1,417
PHP:
<?php 
$fp = @fsockopen($srvip, $srvport, $errno, $errstr, 1);
if (!$fp) {
echo '<img src="/images/offline.png" alt="offline" />';
} else {
echo '<img src="/images/online.png" alt="online" />';
fclose($fp);
} ?>


---------- Post added at 10:02 AM ---------- Previous post was at 10:01 AM ----------

if you want to use double quotes inside double quotes you have to escape them, or simply use simple quotes for echo and then you can use double quotes as much as you want
 
Skilled Illusionist
Joined
Oct 8, 2010
Messages
332
Reaction score
24
PHP:
<?php 
$fp = @fsockopen($srvip, $srvport, $errno, $errstr, 1);
if (!$fp) {
echo '<img src="/images/offline.png" alt="offline" />';
} else {
echo '<img src="/images/online.png" alt="online" />';
fclose($fp);
} ?>


---------- Post added at 10:02 AM ---------- Previous post was at 10:01 AM ----------

if you want to use double quotes inside double quotes you have to escape them, or simply use simple quotes for echo and then you can use double quotes as much as you want

Thanks worked!
 
Back
Top