php - Variable not posting to what i believe is dynamic image? -


i have simple port check wish post online/offline status's believe dynamic image. don't give me , error or nothing if it's online not post offline or offline post resource id #1 here's code:

<?php $ip      = $_get["ip"]; $port    = $_get["port"]; $online  = "online"; $offline = "offline";  $status = (fsockopen($ip, $port)); if ($status) {     $online; } else {     $offline; }  // create blank image , add text $im         = imagecreatetruecolor(215, 86); $text_color = imagecolorallocate($im, 233, 14, 91);  // sets background light blue $lightblue = imagecolorallocate($im, 95, 172, 230); imagefill($im, 0, 0, $lightblue);  //server information imagestring($im, 7, 5, 5, '3nerds1site.com', $text_color); imagestring($im, 2, 40, 30, $ip, $text_color); imagestring($im, 2, 40, 40, $port, $text_color); imagestring($im, 2, 40, 70, $status, $text_color);  // set content type header - in case image/jpeg header('content-type: image/png');  // output image imagepng($im);  // free memory imagedestroy($im); ?> 

can give me helpful info this?

here output: enter image description here

this meaningless:

$status = (fsockopen($ip, $port)); if ($status) {     $online; } else {     $offline; } 

it cause of problem, because $status never printable (the lines inside conditionals not change value @ all). either false (in case see nothing expect "offline") or resource (in case see "resource id #1").

replace of above code with

$status = fsockopen($ip, $port) ? $online : $offline; 

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -