Jump to content

PHP + VBA = Grr!


mandi_08

Recommended Posts

Hi there.

I have two codes, one PHP, one VBA. Both codes work individually.

I need to blend them, so that the PHP code can run and include the VBA... I think an example would be easier to understand.

 

PHP code:

<?php
#
function push2phone($server,$phone,$data)
{
$xml = "xml=".$data;
$post = "POST / HTTP/1.1\r\n";
$post .= "Host: $phone\r\n";
$post .= "Referer: $server\r\n";
$post .= "Connection: Keep-Alive\r\n";
$post .= "Content-Type: text/xml\r\n";
$post .= "Content-Length: ".strlen($xml)."\r\n\r\n";
$fp = @fsockopen ( $phone, 80, $errno, $errstr, 5);
if($fp)
{
fputs($fp, $post.$xml);
flush();
fclose($fp);
}
}
##############################
$xml = "<AastraIPPhoneTextMenu>\n";
$xml .= "<Title>Push test</Title>\n";
$xml .= "<MenuItem>\n";
$xml .= "<Prompt>Call Customer</Prompt>\n";
$xml .= "<URI>Dial:9custnumber</URI>\n";
$xml .= "</MenuItem>\n";
$xml .= "</AastraIPPhoneTextMenu>\n";
push2phone("1xx.0.0.2xx","1xx.0.0.2xx" ,$xml);
?>

 

VBA Code:

CustName = Me.CustName
Number = Me.Number
Mob = Me.Mob

If IsNull(Number) = False Then
    MenuNumber = "<MenuItem>" & _
"<Prompt>Call " & CustName & "</Prompt>" & _
"<URI>Dial:9" & Number & "</URI>" & _
"</MenuItem>"
Else: MenuNumber = ""
End If

If IsNull(Mob) = False Then
    MenuMob = "<MenuItem>" & _
"<Prompt>Call " & CustName & " Mobile</Prompt>" & _
"<URI>Dial:9" & Mob & "</URI>" & _
"</MenuItem>"
Else: MenuMob = ""
End If

xml = "xml=<AastraIPPhoneTextMenu>" & _
"<Title>Call Customer</Title>" & _
MenuNumber & MenuMob & _
"</AastraIPPhoneTextMenu>"

 

 

I need to be able to run the VBA and put the resulting xml into the PHP (replacing the hardcoded xml) preferably without having to save it anywhere.

 

The php is a file that I call from a button on my phone; which throws up a number and dials when I lift the reciever.

The VBA selects the name and number(s) from the open form on the users database.

 

I guess it also needs someway of sending the request to the right phone / computer...

 

Basically I want to either click a button on the database that will pass the number(s) to the phone for easy dialing; or press a button on the phone that will query the database and viola.

 

Would someone please help me figure this one out?

 

(I'm using trixbox 2.6.1 for the phone system and Aasta 55i's if anyone's familiar with those)

 

Thanks

Mandi

 

Edit: The database we have is currently an Access 2003 one, split with backend on server and obviously front end on each users PC.

We're upgrading to MSSQL soon.

Link to comment
https://forums.phpfreaks.com/topic/123912-php-vba-grr/
Share on other sites

None for absolute PHP beginners unfortunately. I've got a nice book, but it's in my native language.

 

For connecting PHP to Access you'd probablu need ODBC and for MSSQL there's a dedicated extension (although it might also work with ODBC... I'm not sure.

Link to comment
https://forums.phpfreaks.com/topic/123912-php-vba-grr/#findComment-639659
Share on other sites

$conn = mysql_connect( "HOST", "USR", "PWD", 0, 65536 ); 
mysql_select_db( "DBNAME" ); 
$ivalue=1; 
$jvalue=2; 
$res = mysql_query( "call myproc($ivalue,$jvalue)" ) or die( mysql_error() ); 
while( $row = mysql_fetch_row( $res )) { 
  foreach( $row as $cell ) echo $cell, " "; 
  echo "<br/>"; 
} 
close( $conn ); 

 

I've found this which says that it calls a stored procedure from MySQL.

Does it look possible to anyone that this could be modified for calling a stored procedure from Access?

 

Thanks

Mandi

Link to comment
https://forums.phpfreaks.com/topic/123912-php-vba-grr/#findComment-639727
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.