Jump to content

elentz

Members
  • Content Count

    228
  • Joined

  • Last visited

Everything posted by elentz

  1. I wonder how I missed that... Anyway it works like it should. Thank you Barand!!
  2. got it, no errors now.. I didn't correctly connect to Mysql either. Had to fix that. No update to the DB yet It reads the table contents. Just to show what I am working with, mostly from barand. I do get the echo connected successfully Thanks // Create connection try { $db = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password); // set the PDO error mode to exception $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); echo "Connected successfully"; } catch(PDOException $e) { echo "Connection failed: " . $e->getMessage(); }if ($_SERVER['REQUEST_METHOD']=='POST') { $updt = $db->prepare("UPDATE extensions SET reset = ? WHERE id = ? "); foreach ($_POST['extid'] as $id) { //$reset = isset($_POST['reset'][$id]) ? $_POST['reset'][$id] : 0; // if checkbox wasn't posted then it is "0" $updt->execute; } } // // GET EXTENSIONS DATA // // Check connection if ($db->connect_error) { die("Connection failed: " . $db->connect_error); } $exdata = ''; $res = $db->query("SELECT id , extension , reset FROM extensions "); foreach ($res as $r) { $chk = $r['reset']==1 ? 'checked':''; $exdata .= "<tr><td>{$r['extension']}</td> <td> <input type='hidden' name='extid[]' value='{$r['id']}'> <input type='checkbox' name='reset[{$r['id']}]' value='1' $chk> </td> </tr>\n"; } ?> <html> <head> <meta name="generator" content="PhpED 18.0 (Build 18044, 64bit)"> <title>Reboot Phones</title> </head> <body> <h1>Extensions</h1> <form method='post'> <table> <tr><th>Extension</th><th>Reset</th></tr> <?=$exdata?> </table> <input type='submit' name='btnSub' value='Submit'> </form> <button type="button"><a href="restart.php">Click to reboot the phones</a></button> </body> </html>
  3. Hmm, My system is using php version 5.6 I cannot change it either. Would that be the reason that the http error log throws that error?
  4. I have the script retrieving the info from the table so the connection is correct. The submit doesn't update the table. In the logs I am getting this: mysqli_stmt::execute() expects exactly 0 parameters, 1 given on line 20 $updt->execute( [ $reset, $id ] ); I also have to comment out this line in order for the page to work as above $reset = $_POST['reset'][$id] ?? 0; // if checkbox wasn't posted then it is "0"
  5. Sometimes I might not make my needs as clear to others as it might appear in my head. Thanks fo ryour help
  6. got it. I originally envisioned a bunch or rows with a checkbox on the end. check all the boxes you want, click a submit button to update the DB and run another page to reboot the phones. If I misspoke and indicated that I wanted to use the checkbox as a submit type of operation I apologize, not what I meant. I haven't had anytime to work on this at all today, maybe tomorrow Thanks
  7. I think I have the idea. Thanks
  8. Ah I think I understand now
  9. Instead of a submit button could a checkbox work? What about a Yes/No dropdown? I want to select the phones I want to restart, update a DB table and then use a submit button to go to another page that will run a query to reset the phones.
  10. I do have a primary key assignedto the id field
  11. ginerjm That sounds like the way to go, I could have any number of rows and updating as each is checked would be best. Gizmola, I think I do have a primary key on that table, can't check from home tho.
  12. I think I get what you are saying. I will see what I can do. Thanks
  13. I do have some code. $sql = "select * from extensions"; $result = mysqli_query($link,$sql) or die(mysql_error()); echo "<table border='3'> <tr> <th>Extension #</th> <th>Reboot</th> </tr>"; while($row = mysqli_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['extension'] . "</td>"; echo "<td>'."<input type='checkbox' class='form' value='1' name='checkbox[" . $row['reset'] . "]' />".'</td>"; echo "</tr>"; } echo "</table>"; ?> I want to a. show the current value of the row reset and b. to have the ability to check the checkbox and change the value in the mysql table. I know I need to make the whole thing a form so that it can update the DB
  14. I have a need to create a form that will get info from a mysql table, show that info, two fields one of which I want to be a checkbox that will need to update the table with either a 0 or a 1. I will later use that info. I have searched all over and haven't found what I am looking for. I can find tutorials for creating checkboxes but nothing what I need / want
  15. This did the trick! $sql = "select extension from extensions"; $result = mysqli_query($link,$sql) or die(mysql_error()); while($row = mysqli_fetch_array($result)) { $out = shell_exec("asterisk -rx 'sip notify CQ_Phone-Reboot " . $row['extension'] . "'"); //echo str_replace("\n", "<br/>", $out); } Thanks so much for the help !
  16. Here's all I have at the moment. The table does populate with the correct info $sql = "select extension from extensions"; $result = mysqli_query($link,$sql) or die(mysql_error()); echo "<table border='3'> <tr> <th>Extension #</th> </tr>"; while($row = mysqli_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['extension'] . "</td>"; } echo "</table>"; //$phones = "SELECT extension FROM extensions where extension IN(".implode(',',$array).")"; //$phones = array(201,202,204); foreach ($result as $phone) { $out = shell_exec("asterisk -rx 'sip notify CQ_Phone-Reboot $phone'"); echo str_replace("\n", "<br/>", $out); } ?> Thanks
  17. Thanks for the reply. Using your suggestion I am getting this: Undefined variable: array in /var/www/html/cqadmin/Assign/restart.php on line 23 Warning: implode(): Invalid arguments passed in /var/www/html/cqadmin/Assign/restart.php on line 23 Line 23 is the new code. Barand Point taken
  18. I have put together a method to reboot my SIP phones. I can use an array to feed the foreach and it works fine. Now I need to take a step or two further. I want to use the result of a query in the array. The next step would be to instead of having all the extensions in the array , to be able to select extensions from a form. But for now getting the initial array is what I am needing help with. //*****This doesn't work ******* //$phones = "SELECT extension FROM `extensions`IN(".implode(',',$array).")"; //******This works******** $phones = array(201,202,204); foreach ($phones as $phone) { $out = shell_exec("asterisk -rx 'sip notify CQ_Phone-Reboot $phone'"); echo str_replace("\n", "<br/>", $out); } Thanks
  19. You were right using php curl worked out just fine. a couple lines and it allworks Thank you
  20. I left out the echo $output in the code. Darn copy and paste. My ignorance of php cURL is why I guess,
  21. I am trying to get a simple thing working. I have a domain with google that I want to change the point to IP when I access a PHP page. I have a DB table with settings that I am using for the username, password, etc. The issue is that the command to change the IP always sends the same IP. No matter what I try. I have tried assigning a fixed entry for the variable $localip, I have set that variable to 0 ahead of the query to get the info from the table. Nothing I do will change the variable in the command. I can manually put the command in a browser and it will perform the change. Can anyone comment on what I am missing here? <?php ini_set("display_errors", 1); ini_set("track_errors", 1); ini_set("html_errors", 1); error_reporting(E_ALL); require('/var/www/html/cqadmin/utils/connect.php'); $sql = "SELECT * FROM `failover` LIMIT 0, 30"; $result = mysqli_query($link,$sql) or die(mysql_error()); $row = mysqli_fetch_array($result); $localip = ($row['localip']); $dnsusername = ($row['dnsusername']); $dnspassword = ($row['dnspassword']); $domain = ($row['failoverurl']); $location = ($row['location']); $dealer = ($row['dealer']); $output = shell_exec("curl -s https://$dnsusername:$dnspassword@domains.google.com/nic/update?hostname=$domain&myip=$localip"); mysqli_close($link); ?> I get no errors on the page and if I echo $output I get a nochng message back from Google Thanks for looking!!
  22. ginerjim Yes It is a config file to tell a phone to go get updated firmware. The phone will only use its mac .cfg as its file. So I can make a "Master.cfg" file and I will have a list of mac addresses will need to be used to create individual .cfg files. All the files will be in the same directory when done. this is a PIA to say the least.
  23. No code yet I am looking for suggestions. I have a common config file that I will need to rename many times the common file name would change but the extension would stay the same. I will only need to do this once (I hope)
  24. I am looking for a way to take a "default" file and create copies of the default file and rename with the entries in a list in a text file. I will have about 100 entries in the list. Fishing for ideas. 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.