Jump to content

Muggins

New Members
  • Posts

    6
  • Joined

  • Last visited

Everything posted by Muggins

  1. My question was how do I send the requery at intervals, or perhaps there is a better way to do it.
  2. Hi Out of my depth here: I have some automation running on a hacked livebox. I want to socket connect, then send an instruction. Problem is the response is constantly changing and I need to somehow requery and parse the result at intervals like 5 seconds. Just beginning to learn PHP so be kind if there is an easy answer. Here is some cut down script. <?php switch ($_REQUEST['btn_submit']) { case "Liv Boost": $response = send("boost liv 1"); break; case "Liv OFF": $response = send("boost liv 0"); break; case "Requery": $response = send(""); } function send($sendstring) { $fp = fsockopen("xx.xx.xx.xx", 9996, $errno, $errstr, 10); fwrite($fp, $sendstring); sleep(2); return fread($fp, 2056); fclose($fp); } function parse($RD,$par1,$par2,$par3) { $pos=strpos($RD,$par1); If ($pos > 0){return substr($RD, $pos + $par2 , $par3);} } ?> <html> <head id="Head1" runat="server"> <title>Home Automation</title> </head> <form method="POST"> <input type="submit" name="btn_submit" value="Liv Boost" /> <input type="submit" name="btn_submit" value="Liv OFF" /> <input type="textbox" name="rowID" value="<?php echo parse($response,"livboostcounter",46,5); ?>" /></br> <input type="submit" name="btn_submit" value="Requery" /> </form> </body> </html>
  3. Apologies but I'm not accustomed to posting on forums. My initial post was a feeler to see if there was a simple answer to a simple question ie Can you populate a textbox from within a function. I didn't want to complicate the post by reference to TCP sockets, parsing etc. Anyway thanks got an answer function getXYZ() { return array(1,2,3); } $array = getXYZ(); $x = $array[1]; $y = $array[2]; $z = $array[3];
  4. Again thanks for the response but, the function that I'm using is parsing a long TCP response from a server and pulling out various bits of information. I only want to run it once. I'm new to PHP, maybe a function can return an array that I can use to populate the boxes. John
  5. Hi PravinS Thanks for that but the function is returning 10 different responses to 10 textboxes. John
  6. Hi How do I output to a textbox from within a function: I know I can call the function and send a response from it to the textbox but the function is complex and sends to 10 boxes. thanks <?php $response = "hello"; function test() { $response = "hello"; } ?> <html> <input type="textbox" name="xx" value="<?php echo $message; ?>" />
×
×
  • 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.