mandi_08 Posted September 12, 2008 Share Posted September 12, 2008 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 More sharing options...
Mchl Posted September 12, 2008 Share Posted September 12, 2008 I think you'd better rewrite VB code into PHP. I'm not sure if PHP and VB can be merged this way... Link to comment https://forums.phpfreaks.com/topic/123912-php-vba-grr/#findComment-639653 Share on other sites More sharing options...
mandi_08 Posted September 12, 2008 Author Share Posted September 12, 2008 Yeah that's what i was thinking too; however my experience of PHP is limited to copy&pasting a 'php include' into a website I made about 7 years ago. Are there any good tutorial / help sites that you know of? Link to comment https://forums.phpfreaks.com/topic/123912-php-vba-grr/#findComment-639655 Share on other sites More sharing options...
Mchl Posted September 12, 2008 Share Posted September 12, 2008 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 More sharing options...
mandi_08 Posted September 12, 2008 Author Share Posted September 12, 2008 Okay, thanks. I'll go look at those links now. I'm sure I'll fudge it eventually Link to comment https://forums.phpfreaks.com/topic/123912-php-vba-grr/#findComment-639669 Share on other sites More sharing options...
mandi_08 Posted September 12, 2008 Author Share Posted September 12, 2008 $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 More sharing options...
Mchl Posted September 12, 2008 Share Posted September 12, 2008 Certainly not through mysql extension (which, I was sure, didn't allow stored procedures). Link to comment https://forums.phpfreaks.com/topic/123912-php-vba-grr/#findComment-639730 Share on other sites More sharing options...
mandi_08 Posted September 12, 2008 Author Share Posted September 12, 2008 Darnit lol Ah well. Back to google. *trundles off* ... *trundles back* Thanks Mchl, you're being very helpful *trundles off again* Link to comment https://forums.phpfreaks.com/topic/123912-php-vba-grr/#findComment-639741 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.