473,386 Members | 1,815 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

php script why if else not working

this script gives the result below when ping is good, a numerical value i think in the form of a string
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. function pinger ($serverIP)
  3. {
  4.     $pingReturn = exec ('ping ' .$serverIP );
  5.     return $pingReturn ;
  6.  
  7. }
  8. $tmp1 = explode(',' , pinger("localhost"));
  9. echo "$tmp1[2] \n";
  10. $newstring=substr($tmp1[2],10);
  11. echo "$newstring \n";
  12. $finalstr=substr_replace($newstring ,"",-2);
  13. echo $finalstr;
  14. ?>

Average = 0ms
0ms
0 is $fianlstr


when ping is bad --- $finalstr is (100% los ------- yes exactly this (100% los

later in the script i have an if elseif statements
Expand|Select|Wrap|Line Numbers
  1. if ($finalstrng <= 50) {$status = "good";}
  2.                 elseif ($finalstrng > 50 && $finalstrng <= 100){$status = "congested";}
  3.                 else {$status = "bad";}
but when $finalstrng is (100% los the status still says good

Please help need to get $finalstrng say bad when not a numeric value
Thanks
Oct 1 '10 #1
2 1482
I think you might have a problem with the variables in your script.

change the variable $finalstrng to $finalstr
Oct 1 '10 #2
ziycon
384 256MB
It looks like the value is always 0 which would make it always 'good', like paulrajj said, check your variable names and that your using the correct one.
Oct 1 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Rob | last post by:
Access Gurus, This script was used to view the reports on the web by choosing a date on or before the current day.Recently it stopped working and i am not able to figure where the problem is. ...
1
by: aaronic | last post by:
I took a script off another site for resizing an image using GD Tools. It works properly keeping the aspect ratio the same except for when the source image is a square, and the thumbnail you want to...
12
kamill
by: kamill | last post by:
I have done a logout page for logout from admin section and provides a link to logout from admin section.Whenever i clicked on logout link it redirected to index.php of admin section......BUT when i...
8
by: shyamg | last post by:
plzzz help me............
2
by: swetha06 | last post by:
Hi all, Executed the following javascript code through localhost...but the script is not working at all.Is the syntax of indexOf correct? The code does the following..checks if a valid...
6
by: blackice | last post by:
hello all ..., first i would thank all the people who are in this forums cause they are very helpful ..., By the way i had some posts hers about comment out the named.conf file the script is...
2
by: lynx129 | last post by:
Hi there , I have php script that works fine under my server but I dont know how to put the html code inside my site. feedback.html <html dir="rtl"> <head> <title> ????? ??? </title>...
5
by: camphor | last post by:
hi, I have found an upload script in hotscripts and have implemented it into the website, I followed the installation steps to 'give write permissions to php on the upload folder (which is...
1
by: filch | last post by:
Hi, I am new to this forum ... so hello to all! I am trying to get a script working which will show or hide a table based on a user checking or unchecking a parent checkbox. This is the...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.