COM component Error in php 5

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ahmedfaraz
Forum Newbie
Posts: 2
Joined: Mon Jan 11, 2010 6:40 am

COM component Error in php 5

Post by ahmedfaraz »

Hi,

I am using a third party COM component in PHP. I have installed WAMP PHP 4.4.4 with Apache 2.0.59 on Windows XP SP2 and it runs perfectly fine on it.

Now I want to upgrade PHP and Apache versions on my server due to some security reasons. I have installed XAMPP with PHP 5.3 and Apache 5.2.12 and it gives me error. COM component is successfully created but gives error when passing parameter to function e.g. Connect(int value).

There are two methods to connect to the server:

-- Connect(integer value [branch]) => In this method, parameter is mandatory which is of integer type.
-- ConnectSpecific(integer value [branch], string value [IP], int value [port], int value
[timeout]) - Only first parameter is mandatory which is of integer type.

Following is the code:

Code: Select all

<?php
 
 
$oid = 5;
 
$input = "";
 
$branch = 0;
$ip_address = "151.171.1.254";
$port = 3011;
$timout = 60;
 
 
$Link = new COM("object.Name");
 
$result = $Link->ConnectSpecific($branch ,$ip_address, $port, $timout); // error line
//$result = $Link->Connect($branch); // error line
 
if($result) {
    $response = "";
    $sendResult = $Link->Send($input, $response);
         
    if($sendResult) {
        echo "success";
    }
    else {
        echo "Unable to send file...";
    }           
    $Link->Disconnect();
}
else {
    echo "Unable to connect with Server";
}
?>
 
As IP address, port and timeout parameters in the function ConnectSpecific() are optional. Only branch parameter is mandatory.

Code: Select all

 
$result = $Link->Connect($branch); // Line # 17
 
Above line gives error:
Fatal error: Uncaught exception 'com_exception' with message 'Parameter 0: Type mismatch. ' in C:\xampp\htdocs\newtest.php:17 Stack trace: #0 C:\xampp\htdocs\newtest.php(17): com->Connect(0) #1 {main} thrown in C:\xampp\htdocs\newtest.php on line 17

Please see the Images for the actual error message.

Thanks.
Attachments
22.jpg
22.jpg (43.16 KiB) Viewed 698 times
11.jpg
11.jpg (42.78 KiB) Viewed 698 times
Post Reply