PHP, COM, Apache, Windows 2000 Professional

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
psmshankar
Forum Commoner
Posts: 96
Joined: Tue Aug 06, 2002 4:25 am
Location: India

PHP, COM, Apache, Windows 2000 Professional

Post by psmshankar »

hi,
using VB, i developed a COMTest.dll that contains a class by name "clsTest". I put this dll in to my server running win 2000 professional, apache 1.3, php 4.3.1
I registered that the dll using "regsvr32". Fine.
I want to use this dll in my php program. so tested it with

Code: Select all

<?php
$objTest = new COM("COMTest.clsTest") or die("Unable to instantiate clsTest component");?>


when i run this, a small pop-up window comes up with following error:
php.exe has generated errors..........

etc..
by saying, the page also sows error
The server encountered an internal error or misconfiguration and was unable to complete your request


All the normal php programs are working fine...only when i use COM its showing problem...i think it could not able to instantiate??
the COM settings in my php.ini file is
[com]
; path to a file containing GUIDs, IIDs or filenames of files with TypeLibs
;com.typelib_file =
; allow Distributed-COM calls
com.allow_dcom = true
; autoregister constants of a components typlib on com_load()
com.autoregister_typelib = true
; register constants casesensitive
com.autoregister_casesensitive = false
; show warnings on duplicate constat registrations
com.autoregister_verbose = true
to check whether my registered dll is working fine, i used the same dll in visual basic program in the server itself and it worked fine..
do i need to set anything... i am using win2k professional...
please help me out... :(
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

what does COMTest.clsTest expose?
psmshankar
Forum Commoner
Posts: 96
Joined: Tue Aug 06, 2002 4:25 am
Location: India

Post by psmshankar »

in that COMTest.cls, i am trying to find whether a device is attached or not.. i am using Nokia Card Phone for my application..
using Nokia SDK, i compiled the dll in VB. That class uses the SDk and chk whether the device is connected or not..
just to start with..
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

naaa, that's not what I meant ;)
It was more about methods, constants, enumerations.
Any complex parameter, either [in]/[out,retval]?
Instantiating the object is enough to crash the system?

Where does

Code: Select all

<?php
function doTest()
{
	echo 'new com'; flush();
	$objTest = new COM("COMTest.clsTest") or die("Unable to instantiate clsTest component");
	echo 'unset object'; flush();
	unset($objTest);
	echo 'leave function'; flush();
}

echo 'call function'; flush();
doTest();
echo 'end script'; flush();
?>
crash - if?
psmshankar
Forum Commoner
Posts: 96
Joined: Tue Aug 06, 2002 4:25 am
Location: India

Post by psmshankar »

Contains following properties
1.DeviceStatus
2.ErrorNumber
3.ErrorDesc

and the following function:
1.CheckDeviceStatus

Code: Select all

<?php
$objTest = new COM("COMTest.clsTest") or die("Unable to instantiate clsTest component");

$objTest->CheckDeviceStatus();
$DevStatus = $objTest->DeviceStatus;
if($DevStatus==0)
{
echo "The Nokia Card Phone has been removed.<br>";
echo "Cannot continue operation.";
}
unset($objTest);
?>
psmshankar
Forum Commoner
Posts: 96
Joined: Tue Aug 06, 2002 4:25 am
Location: India

Post by psmshankar »

CheckDeviceStatus is the function within which the VB code check the status of the device. and a value will get stored in the DeviceStatus property ..

i need to call the function and then only i can get the value in that "DeviceStatus" member variable of the dll
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

ok, first let's stick to the current problem.
At which point does it crash?
psmshankar
Forum Commoner
Posts: 96
Joined: Tue Aug 06, 2002 4:25 am
Location: India

Post by psmshankar »

when i run the above php code, it says php exe error...
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

which doesn't tell you much about where it does crash.
Might be useful to learn more about the exact location the script crashes ;)

Code: Select all

<?php
function dotest()
{
	echo 'create object'; flush();
	$objTest = new COM("COMTest.clsTest") or die("Unable to instantiate clsTest component");
	echo 'invoke function'; flush();
	$objTest->CheckDeviceStatus();
	echo 'get property'; flush();
	$DevStatus = $objTest->DeviceStatus;
	echo 'type of property', gettype($DevStatus); flush();
	if($DevStatus==0)
	{
		echo "The Nokia Card Phone has been removed.<br>";
		echo "Cannot continue operation.";
	}
	echo 'unset object'; flush();
	unset($objTest);
	echo 'leave function'; flush();
}


echo 'call dotest'; flush();
dotest();
echo 'exit script'; flush();
?>
psmshankar
Forum Commoner
Posts: 96
Joined: Tue Aug 06, 2002 4:25 am
Location: India

Post by psmshankar »

now i am getting the following..
call dotestcreate objectinvoke functionget propertytype of propertyintegerThe Nokia Card Phone has been removed.
Cannot continue operation.unset objectleave functionexit script
it prints that nokia device is not connected... whereas it is connected and by using the same DLL in visual basic, and with same class and methods it is returning corretly and says that nokia phone is connected...
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

but it does not crash anymore.
That's progress, isn't it? Image
psmshankar
Forum Commoner
Posts: 96
Joined: Tue Aug 06, 2002 4:25 am
Location: India

Post by psmshankar »

yeah a good progress, but y suddenly it showed no device???
if there is device then i need to instantiate another class and use the member functions of this class to send SMS...
psmshankar
Forum Commoner
Posts: 96
Joined: Tue Aug 06, 2002 4:25 am
Location: India

Post by psmshankar »

still it returns the value 0 for the DevStatus

Code: Select all

<?php
$DevStatus = $objTest->DeviceStatus
?>
meaning that no hardware found...
but i have plugged in the nokia hardware and its working fine.. in VB i get the DevStatus value as 1, which means it found the hardware...

Do i need to do any setting for the COM classes so that the PHP can get correct values... even here i wonder as the PHP successfully able to instantiate the class.. but getting the wrong values from the property...
i really donno...not able to move up...
psmshankar
Forum Commoner
Posts: 96
Joined: Tue Aug 06, 2002 4:25 am
Location: India

Post by psmshankar »

oh my god... i just copied the server vb program into the application server(running win2k) and started the debugger... i run the php sample file and to the surprise, i get the Devstatus value as 1 in the vb dll(when i step into each statement using F8 key) and php gets the correct value and prints nokia found..

but if i don't run the debugger and just run the php script in the browser it shows DevStatus Value 0 and nokia NOT found...
how come???? 8O :? :x :roll: :cry:
Post Reply