Solved

PHP, WMI, COM object and getting the array value

Posted on 2011-02-24
3
855 Views
Last Modified: 2012-05-11
This code

      define ( 'CPU_NAME', '.' );

      $obj = new COM ( 'winmgmts:{impersonationLevel=impersonate}//' . CPU_NAME . '/root/cimv2' );

      if ( is_object ( $obj ) )
      {
            $process = $obj->execquery ( "SELECT * FROM Win32_BIOS" );

            if ( $process->count > 0 )
            {
                  foreach($process as $row){
                  	echo"BIOS: $row->bioscharacteristics<br />";
                  }
            }
            else
            {
                  echo 'error';
            }

            $obj = null;
      }
      else
      {
            echo 'no object';
      }

Open in new window


produces an error

Catchable fatal error: Object of class variant could not be converted to string in C:\xampp\htdocs\aa\index.php on line 71

I'm aware of the WMI classes and the property value of the BIOS characteristics as it is an array of integers separated with "," - or maybe just string value of integers with ",". Most of the Win32 classes does not give this error (Win32_Account for example). Caould you guide me how to deal with these kind of situations ?
0
Comment
Question by:Lukasz Chmielewski
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 17

Accepted Solution

by:
Learnctx earned 500 total points
ID: 34977708
I have never done anything with PHP, but as far as doing this in VBScript or PowerShell I would usually join this particular property array into a single string and then use it.
[string]::Join(",",(GWMI -Q "SELECT bioscharacteristics FROM Win32_BIOS").BiosCharacteristics)

Open in new window

I'm assuming in PHP you can do something similar?
0
 
LVL 27

Author Comment

by:Lukasz Chmielewski
ID: 34977721
Thanks for response, I'll try to convert it to PHP and get back to you.
0
 
LVL 27

Author Closing Comment

by:Lukasz Chmielewski
ID: 34987917
Well, partially. Made me code some more to finally get the value into an array.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
can i read my emails on lamp ftp 4 69
Edit my bash script 16 46
Considerations PHP using multiple locations 9 33
Which is best Image Resizing Web service 11 38
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question