Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8488115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:26:31+00:00 2026-06-10T21:26:31+00:00

I have a database that I have created that I use to keep up

  • 0

I have a database that I have created that I use to keep up with my list of static IPs on my network. I have a page that lists the ips in order, my script to list the ips and other data from the database works, but I want to add a script to ping each ip address and tell whether it’s up or not, here is the code I have to display everything:

$dbConn = connectToDb();

$sql= <<< END

SELECT *
FROM `ipadds` 
ORDER BY oct1 ASC, oct2 ASC, oct3 ASC, oct4 ASC;

END;

$result=mysql_query($sql) or die(mysql_error()); 



$options=""; 



while ($row=mysql_fetch_array($result)) {

    $oct1=$row['oct1']; 
    $oct2=$row['oct2']; 
    $oct3=$row['oct3']; 
    $oct4=$row['oct4']; 
    $SubnetMask=$row['SubnetMask']; 
    $Hostname=$row['Hostname']; 
    $MAC=$row['MAC']; 
    $Description=$row['Description']; 
    $DeviceType=$row['DeviceType']; 
    $Location=$row['Location']; 
    $Comments=$row['Comments']; 

    $options.="<tr><td><a href=editcomputer.php?queryID=$id><img src=images/edit.gif alt=print border=0></a> <a href=deletecomputer.php?queryID=$id><img src=images/edit-delete-icon.png alt=print border=0></a></td><td><a href='HTTP://$oct1.$oct2.$oct3.$oct4' target=_blank>$oct1.$oct2.$oct3.$oct4</a></td><td>$SubnetMask</td><td>$Hostname</td><td>$MAC</td><td>$Description</td><td>$DeviceType</td><td>$Location</td></tr>";

}
?> 
<center>

<font size=-1>

<img src="images/edit.gif"> - Edit Computer<br>

<img src="images/edit-delete-icon.png"> - Delete Computer<br>

</font>

<font size="2">

<table>

<tr>

<td>

<hr>

</td>

</tr>
<table cellpadding="15" border="1">
<tr>
<td>

</td>
<td>
<u>IP Address</u>
</td>
<td>
<u>Subnet Mask</u>
</td>
<td>
<u>Hostname</u>
</td>
<td>
<u>MAC Address</u>
</td>
<td>
<u>Description</u>
</td>
<td>
<u>Device Type</u>
</td>
<td>
<u>Location</u>
</td>

<?=$options?>
</table>

I want to add another row to my table and have it as a “Status” of Up or Down, any suggestions?

I found this code, it works all by itself and I specify the address, but can’t get it to work in my “while” statement:

function pingAddress($ip) {
    $pingresult = exec("ping -n 3 $ip", $outcome, $status);
    if (0 == $status) {
        $status = "alive";
    } else {
        $status = "dead";
    }
    echo "The IP address, $ip, is  ".$status;
}

pingAddress("ip addres of host here");
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T21:26:33+00:00Added an answer on June 10, 2026 at 9:26 pm

    Without mentioning that you should not be using mysql_* functions (oops, I just did), all you have to do is change your function to return a value:

    function pingAddress($ip) {
        $pingresult = exec("ping -n 3 $ip", $outcome, $status);
        if (0 == $status) {
            return true;
        } 
        return false;
    } 
    

    then in your loop:

    while ($row=mysql_fetch_array($result)) {
        [...]
        if (pingAddress($ip) === true) {
            // IP is up
        }
        else {
            // IP is down
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have information stored in a database that I want to use to create
I have a database that I have created using SQL Server Developer 2008. I
I have an existing database(myDatabse) that I created with Microsoft Sql Managenent studio and
I have a mysql database that looks like this: |id | city | created
I have a DB that I created using the OOB database initializer, and I
I have created a simple windows service that periodically checks a remote database via
I have a TableLayout that is created programmatically in an Android project. I keep
I have a database table that I use as a queue system, where separate
Let's say that I have a SQLite database that I create in a separate
i have DataBase function that calculate distance by coordinates CREATE OR REPLACE FUNCTION distance(lat1

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.