php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33734 Something strange with COM Object
Submitted: 2005-07-17 14:20 UTC Modified: 2006-12-24 12:34 UTC
Votes:4
Avg. Score:4.5 ± 0.9
Reproduced:4 of 4 (100.0%)
Same Version:3 (75.0%)
Same OS:4 (100.0%)
From: tommy_wei at hotmail dot com Assigned: wez (profile)
Status: Closed Package: COM related
PHP Version: 5CVS-2005-07-17 (dev) OS: win32
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: tommy_wei at hotmail dot com
New email:
PHP Version: OS:

 

 [2005-07-17 14:20 UTC] tommy_wei at hotmail dot com
Description:
------------
I found something strange with COM Object but I'm not sure.
 
My System
- Windows 2000-2003 Server & XP Pro sp2
- IIS ISAPI
- PHP 5.0.4 & 5.1.0b3 & 5.1.0Dev-200507170630
 
My code...
<?php
try{
$com=new COM("Automation_Users");//My Company ActiveX
$index=$com->IndexOf($user);
$target=$com->Items($index);//return user object
$target->Password="password";
$com->Items($index)=$target;//to update user's information
unset($com);
}catch(Exception $exp){
echo $exp->getMessage();
}
?>
 
The problem is at the line -> $com->Items($index)=$target;
 
- PHP 5.0.4
$com->Items($index)=$target;
Error -> Fatal error: Can't use method return value in write context in D:\Project\PHP\Project\functions.php on line 580
 
I don't know why because this works fine with ASP
I changed the code to...
 
$com->Items[$index]=$target;
It works !   I don't understand why it works ?
I never used [] to pass parameter with any COM object.
 
- PHP 5.1.0b3 & 5.1.0Dev doesn't work any way both ($index) [$index]
 
$com->Items($index)=$target;
Error -> Fatal error: Can't use method return value in write context in D:\Project\PHP\Project\functions.php on line 580
 
$com->Items[$index]=$target;
Error -> [0x8002000e] Invalid number of parameters.
 
This made me confuse -"-
 
---------------------------------------
 
I'm not sure this is a bug of my company's activeX or PHP
If you need more information please tell me.

Thank you.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-07-17 14:53 UTC] helly@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

The short answer is PHP is different from ASP.

The long answer is that atm we cannot support the ()= syntax and offer the []= as an alternative.
 [2005-07-17 17:00 UTC] tommy_wei at hotmail dot com
Ok you are right...

You said -> The long answer is that atm we cannot support the ()= syntax and offer
the []= as an alternative

But why this code doesn't work with PHP 5.1.0b3 & The lastest CVS 5.1.0Dev...it works for PHP 5.0.4

<?php
try{
$com=new COM("Automation_Users");//My Company ActiveX
$index=$com->IndexOf($user);
$target=$com->Items[$index];//return user object
$target->Password="password";
$com->Items[$index]=$target;//to update user's information
unset($com);
}catch(Exception $exp){
echo $exp->getMessage();
}
?>

At line >> $target=$com->Items[$index];

Error is >> [0x8002000e] Invalid number of parameters.

Any idea ?
 [2005-07-18 02:26 UTC] sniper@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.


 [2005-07-18 02:43 UTC] wez@php.net
I'd like to see the IDL for the methods you are using there, and find out why it stopped working in 5.1.

The OleView tool is the best bet for this; if you don't have it, the com_print_typeinfo() function in PHP is better than nothing.
 [2005-07-18 14:26 UTC] tommy_wei at hotmail dot com
Thank you so much "wez@php.net" your answer is very nice...listen carefully in the problem and find out why.

I have no any Oleview tool but, I get an idea which make the same result, you can use your Oleview tool to view something you want.

Try this code...it's well known COM Object

<?php
$conn=new COM("ADODB.Connection");
$rs=new COM("ADODB.Recordset");
$conn->Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=".dirname(__FILE__)."\\".basename("Northwind.mdb"));
$sql="Select * From Customers";
$rs->Open($sql,$conn,1,3);
echo "First Record : ".$rs[1]->Name."=".$rs->Fields->Item[1];
$rs->Close();
$conn->Close();
unset($conn,$rs);
?>
//MS Access XP 2002
//MDAC 2.8
-----------------------------------------------------------
Result From 5.0.4

First Record : CompanyName=Alfreds Futterkiste

-----------------------------------------------------------
Result From 5.1.0b3 & 5.1.0Dev200507171830

Fatal error: Uncaught exception 'com_exception' with message 'Error [0x8002000e] Invalid number of 

parameters. ' in D:\Project\PHP\test.php:7 Stack trace: #0 D:\Project\PHP\test.php(7): unknown() #1  

{main} thrown in D:\Project\PHP\test.php on line 7

With catch exception
Fatal error: Error [0x8002000e] Invalid number of parameters.

At line 7 >> echo "First Record : ".$rs[1]->Name."=".$rs->Fields->Item[1];
The point is >> $rs->Fields->Item[1];
-----------------------------------------------------------

Hope this may help...thank you.
 [2005-12-17 05:46 UTC] way dot sun at bellsouth dot com
I first noticed this change, () vs [], in 5.0.5.
5.0.4 uses (), but 5.0.5 onwards uses []. 

Thanks
 [2006-12-24 12:34 UTC] rrichards@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Dec 11 14:02:33 2024 UTC