Jump to content

Nucleus

Members
  • Posts

    13
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

Nucleus's Achievements

Newbie

Newbie (1/5)

0

Reputation

1

Community Answers

  1. So what you're telling me is that If the code in a question is not faultless, you are not dignifying it with an answer. I'm I understanding this correctly? I see this behaviour all the time. If someone has a Guru/Expert/Master tag on their profile, they are more likely to reply the way you do. Arrogantly, instead of constructively. Unfortunately, its people like you preventing others from learning. So here's a lesson for you: Answering to someone offensively and arrogantly, disappoints and discourages them from learning PHP (or anything). I suggest you take some time off PHP and work on your people skills. Sentences like "Guys, please, turn your brains back on. I know this is amateur hour" are a true indication of the way you put yourself on a pedestal. Saying things like these behind the anonymity of your computer is not mature, and surely something you would never say to someone's face. The only logical conclusion if that you are somewhere between 21 to 26 years of age, trying to prove yourself in these forums. I'm sure in a few years, after you've worked for a few multinational corporations, you'll understand what humility is. But you can't go telling people to turn their brains back on, or someone will break your fingers or worst, fire you. I hope I've helped. If I have a PHP question in another 12 years, I'll be sure to contact you directly.
  2. In fact, let me make this really easy for you. ob_flush();flush(); This is from people that actually help with the problem at hand.
  3. @Jacques1 Thanks for pointing out all the things that are wrong with this code, but don't you think that you are making a lot of assumptions here? I mean, why even go into this discussion without even knowing how will this be used? How do you know that this is not in an isolated environment? Test lab? Student exercise? How do you even know that you have the full picture? I meet people trying to prove their knowledge all the time, in internet forums and real life, discussing all sorts of subjects. It seems these people are more focused on pointing out mistakes, proving their knowledge and eventually feeling better about themselves, instead of actually helping with the problem at hand. Did I ask about key authentication? Security? Unprivileged accounts? No. I just asked how to get the output of each computer. That's it! And instead of helping out with the actual question, you found something you're comfortable with to rant about. So before ignoring this topic completely and never return to these forums again, I'll give you another chance to put all this know-how to usefulness. Read the original post and see if you can provide an answer to my question.
  4. I am using this to send a command to multiple Linux computers via ssh. It prints the results after it has processed all computers. How can I see the results after each computer is finished, so I don't have to wait for all computers to finish? <form action="commands.php" method="post" target="main"> <input type="checkbox" name="clients[]" value="192.168.1.11">Client001<br> <input type="checkbox" name="clients[]" value="192.168.1.12">Client002<br> <br/> <select name="commands"> <option value="">Select Command</option> <option value="uptime | sed 's/.*up \([^,]*\), .*/\1/'">Uptime</option> <option value="printf $(free | grep -e-/+ | awk '{print $3/($3+$4) * 100.0 ''}' | cut -d '.' -f1)%%">Memory Usage</option> </select> <br> <br/> <input type="submit" value="Submit" /> </form> <?php include('Net/SSH2.php'); $user = "user"; $pass = "pass"; $ip = $_POST['clients']; $ssh = new Net_SSH2($ip); $cmds = $_POST['commands']; if(!empty($_POST['clients'])) { foreach($_POST['clients'] as $ip) { $ssh = new Net_SSH2($ip); if (!$ssh->login($user, $pass)) {exit('Login Failed');} echo " " . $ssh->exec($cmds) . "<br>"; } } ?>
  5. I am using the below to sent ssh commands through a web interface. Below is an example to get the hostname of a Linux computer. I need to change this form, from a dropdown menu, to checkboxes. I know how to do this in html, but I don't know how to tell php to handle it. Reason is, what if multiple checkboxes are selected? how would target="main" display results from multiple computers? index.html <form action="phpseclib/hostname.php" method="get" target="main"> <select name="clients"> <option value="SelectClient">Select Client</option> <option value="192.168.0.51">Client001</option> <option value="192.168.0.52">Client002</option> <option value="192.168.0.53">Client003</option> </select> <input type='submit' /> </form> hostname.php <?php include('Net/SSH2.php'); include('variables.php'); $ip = $_GET['clients']; $ssh = new Net_SSH2($ip); if (!$ssh->login($user, $pass)) {exit('Login Failed');} echo $ssh->exec('hostname'); ?>
  6. This fixed it <?php include('Net/SSH2.php'); include('variables.php'); $ip = $_GET['clients']; $ssh = new Net_SSH2($ip); if (!$ssh->login($user, $pass)) {exit('Login Failed');} echo $ssh->exec('hostname'); ?>
  7. I am using the below to sent ssh commands through a web interface. For example, to get the hostname of a Linux computer: index.html <form action="phpseclib/hostname.php" method="get" target="_blank"> <select name="clients"> <option value="SelectClient">Select Client</option> <option value="192.168.0.51">Client001</option> <option value="192.168.0.52">Client002</option> <option value="192.168.0.53">Client003</option> </select> <input type='submit' /> </form> hostname.php <?php include('Net/SSH2.php'); include('variables.php'); $ip = $_GET['clients']; $ssh = new Net_SSH2('$ip'); if (!$ssh->login($user, $pass)) {exit('Login Failed');} echo $ssh->exec('hostname'); ?> In hostname.php if I set the $ip variable manually, everything works as expected. But when I use $ip = $_GET['clients']; I get a message saying "Login Failed" When I echo $ip I correctly get the IP Address of the dropdown selection. What I'm I doing wrong here? Thanks
  8. Forgive my ignorance, but do you mean something like this? $result=mysql_query($query); echo mysql_error()
  9. This code <? include("dbinfo.inc.php"); mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM contacts"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); echo "<b><center>Database Output</center></b><br><br>"; ?> <table border="0" cellspacing="2" cellpadding="2"> <tr> <th><font face="Arial, Helvetica, sans-serif">Name</font></th> <th><font face="Arial, Helvetica, sans-serif">Phone</font></th> <th><font face="Arial, Helvetica, sans-serif">Mobile</font></th> <th><font face="Arial, Helvetica, sans-serif">Fax</font></th> <th><font face="Arial, Helvetica, sans-serif">E-mail</font></th> <th><font face="Arial, Helvetica, sans-serif">Website</font></th> </tr> <? $i=0; while ($i < $num) { $first=mysql_result($result,$i,"first"); $last=mysql_result($result,$i,"last"); $phone=mysql_result($result,$i,"phone"); $mobile=mysql_result($result,$i,"mobile"); $fax=mysql_result($result,$i,"fax"); $email=mysql_result($result,$i,"email"); $web=mysql_result($result,$i,"web"); ?> <tr> <td><font face="Arial, Helvetica, sans-serif"><? echo "$first $last"; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo "$phone"; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo "$mobile"; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo "$fax"; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><a href="mailto:<? echo "$email"; ?>">E-mail</a></font></td> <td><font face="Arial, Helvetica, sans-serif"><a href="<? echo "$web"; ?>">Website</a></font></td> </tr> <? ++$i; } echo "</table>"; ?> Gives me this error [04-Feb-2010 09:24:41] PHP Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in /home1/koutouro/public_html/ioannou/example/index.php on line 8 [04-Feb-2010 09:24:57] PHP Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in /home1/koutouro/public_html/ioannou/example/index.php on line 8 [04-Feb-2010 09:25:09] PHP Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in /home1/koutouro/public_html/ioannou/example/index.php on line 8 What I'm I doing wrong? Thanks
  10. It seems that for some reason when I update a record, it overwrites another.
  11. The warning is now gone, but the form does not display the "Thank you! Information updated" message, nor it updates the table. :-\
  12. Hello, I am using this form, to connect on MySQL database and edit the fields "FirstName", "LastName" and "PhoneNumber" in the "Employees" table. <? //connect to mysql include 'connect.php'; //If cmd has not been initialized if(!isset($cmd)) { //display all the fields $result = mysql_query("select * from Employees order by id"); //run the while loop that grabs all the fields while($r=mysql_fetch_array($result)) { //grab the title and the ID of the fields $ID=$r["ID"]; $FirstName=$r["FirstName"]; $LastName=$r["LastName"]; $PhoneNumber=$r["PhoneNumber"]; //make the title a link echo "<a href='edit.php?cmd=edit&id=$id'>$FirstName - Edit</a>"; echo "<br>"; } } ?> <? if($_GET["cmd"]=="edit" || $_POST["cmd"]=="edit") { if (!isset($_POST["submit"])) { $id = $_GET["ID"]; $sql = "SELECT * FROM Employees WHERE id=$id"; $result = mysql_query($sql); $myrow = mysql_fetch_array($result); ?> <form action="edit.php" method="post"> <input type=hidden name="id" value="<?php echo $myrow["id"] ?>"> First Name:<INPUT TYPE="TEXT" NAME="FirstName" VALUE="<?php echo $myrow["FirstName"] ?>" SIZE=30><br> Last Name:<INPUT TYPE="TEXT" NAME="LastName" VALUE="<?php echo $myrow["LastName"] ?>" SIZE=30><br> Phone Number:<INPUT TYPE="TEXT" NAME="PhoneNumber" VALUE="<?php echo $myrow["PhoneNumber"] ?>" SIZE=30><br> <input type="hidden" name="cmd" value="edit"> <input type="submit" name="submit" value="submit"> </form> <? } ?> <? if ($_POST["$submit"]) { $FirstName = $_POST["FirstName"]; $LastName = $_POST["LastName"]; $PhoneNumber = $_POST["PhoneNumber"]; $sql = "UPDATE Employees SET FirstName='$FirstName',LastName='$LastName',PhoneNumber='$PhoneNumber' WHERE id=$id"; //replace the fields with your table name above $result = mysql_query($sql); echo "Thank you! Information updated."; } } ?> My problem is that I get this warning message: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home1/koutouro/public_html/ioannou/edit.php on line 34 As a result I cannot update the database. I started working with PHP and MySQL yesterday, so please be patient with me. Thanks.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.