By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
463,124 Members | 545 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 463,124 IT Pros & Developers. It's quick & easy.

query access database remotely?

P: 90
Before I begin I want to apologise if my explanations are less than clear; that said, I'll try and be as detailed as possible.

User (XP OS, running office 2003) - IP = 1xx.x.x.101
phone system (linux OS, running 'trixbox') - IP = 1xx.x.x.222
phones (aastra 55i IP phones) - IP = 1xx.x.x.201

I want to be able to click a button on the customer record on our database on their computer, and have that customers number sent to the phone, so picking up the phone dials the number.
Still with me?

I have a php file that does what I want, IF I hard code the number and phones IP address into it. Obviously useless in the context I want it. (See bottom of post for code)

I know it's possible to send the info as a hyperlink such as http://1xx.x.x.222/callfromdb.php?number=01234567890&ipadd=1xx.x.x.20 1
(I think that's where I'd have to send it anyway. That's the link I have hard-coded into the phone (before the ?) which worked, but now for some reason doesn't.

This sounds like the most plausible method (from my extremely limited knowledge), so could someone help me modify the code for this method please?

I know about POST and GET, but the tutorials are confusing the heck outta me, and I think I've fried my brain.

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. #
  3. function push2phone($server,$phone,$data)
  4. {
  5. $xml = "xml=".$data;
  6. $post = "POST / HTTP/1.1\r\n";
  7. $post .= "Host: $phone\r\n";
  8. $post .= "Referer: $server\r\n";
  9. $post .= "Connection: Keep-Alive\r\n";
  10. $post .= "Content-Type: text/xml\r\n";
  11. $post .= "Content-Length: ".strlen($xml)."\r\n\r\n";
  12. $fp = @fsockopen ( $phone, 80, $errno, $errstr, 5);
  13. if($fp)
  14. {
  15. fputs($fp, $post.$xml);
  16. flush();
  17. fclose($fp);
  18. }
  19. }
  20. ##############################
  21. $xml = "<AastraIPPhoneTextMenu>\n";
  22. $xml .= "<Title>Call Customer</Title>\n";
  23. $xml .= "<MenuItem>\n";
  24. $xml .= "<Prompt>Call Customer</Prompt>\n";
  25. $xml .= "<URI>Dial:01234567890</URI>\n";
  26. $xml .= "</MenuItem>\n";
  27. $xml .= "</AastraIPPhoneTextMenu>\n";
  28. push2phone("1xx.x.x.222","1xx.x.x.201" ,$xml);
  29. ?>
I can more-or-less understand the code; I just don't know where to begin rewriting it.
Expand|Select|Wrap|Line Numbers
  1. $_REQUEST['number']
apparently features somewhere; or possibly GET instead of request.

If you follow this and understand it, you're a genius and I thank you.
If you need clarification on something, please ask and I'll try my hardest not to make it worse.

Thank you all in advance for any help you can give.
Sep 17 '08 #1
Share this Question
Share on Google+
6 Replies

Expert 5K+
P: 5,058

So all you need, essentially, is to replace the hard-coded number and phone IP address with the values from the GET string?

You could simply do this at the top of the page:
Expand|Select|Wrap|Line Numbers
  1. $phoneNumber = $_GET['number'];
  2. $phoneIP = $_GET['ipaddr'];
And the replace the hard coded lines with those variables.
Like say:
Expand|Select|Wrap|Line Numbers
  1. $data = "<URI>Dial: $phoneNumber</URI>";
  2. myFunction($phoneIP, $data);
Sep 17 '08 #2

P: 90
Expand|Select|Wrap|Line Numbers
  1. $phoneNumber = $_GET['number'];
  2. $phoneIP = $_GET['ipaddr'];
Does it matter where in the code I put that?
Cos I've tried and nothing happens; I just get taken to a blank webpage.

Sep 17 '08 #3

P: 90
Hang on, it kinda works.

It seems to work intermittently.
I went to the page and it work; rang and everything.
Then I tried going again and nothing happened.

I think there must be some sort of delay or something, but I guess that's more phone related than something wrong with the php...

Thank you =)
Sep 17 '08 #4

Expert 5K+
P: 5,058
The delay could be because of the Connection header you set there.
Try changing it from "Keep-Alive" to "Close".

That should tell the phone to close the connection immediately.
Sep 17 '08 #5

Expert 5K+
P: 5,821
Heya, mandanarchi.

Try removing the '@' in front of fsockopen() and looking at this article to see if anything untoward is going on.
Sep 18 '08 #6

P: 90
Thanks both.

Once I'd added it to the VBA (using the 'follow hyperlink' method) all was fine.
My only snag is that it opens IE or FF (depending on default); but I know that's the normal behaviour of the method.

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. #
  3. function push2phone($server,$phone,$data)
  4. {
  5. $phonenumber = $_REQUEST['number'];
  6. $phone = $_REQUEST['phone'];
  8. $xml = "xml=".$data;
  9. $post = "POST / HTTP/1.1\r\n";
  10. $post .= "Host: $phone\r\n";
  11. $post .= "Referer: $server\r\n";
  12. $post .= "Connection: Keep-Alive\r\n";
  13. $post .= "Content-Type: text/xml\r\n";
  14. $post .= "Content-Length: ".strlen($xml)."\r\n\r\n";
  15. $fp = @fsockopen ( $phone, 80, $errno, $errstr, 5);
  16. if($fp)
  17.         {
  18.         fputs($fp, $post.$xml);
  19.         flush();
  20.         fclose($fp);
  21.         }
  22. }
  23. ##############################
  25. $xml = "<AastraIPPhoneTextMenu>\n";
  26. $xml .= "<Title>Call Customer</Title>\n";
  27. $xml .= "<MenuItem>\n";
  28. $xml .= "<Prompt>Call Customer</Prompt>\n";
  29. $xml .= "<Dial>$phonenumber</Dial>\n";
  30. $xml .= "</MenuItem>\n";
  31. $xml .= "</AastraIPPhoneTextMenu>\n";
  32. push2phone("serverIP",$phone,$xml);
  33. ?>
That's my working code. I just follow the hyperlink to http://serverIP/callfromdb.php?phone=[phoneIP]&number=[number2dial] and it works.

Thank you =)
Sep 19 '08 #7

Post your reply

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