PHP Catchable fatal error: Argument 2 passed to Microsoft_WindowsAzure_Storage_Table::insertEntity() must be an instance of Microsoft_WindowsAzure_Storage_TableEntity

Sep 21, 2009 at 8:02 AM
Edited Sep 21, 2009 at 8:05 AM

Hi, I am getting the fatal error message "PHP Catchable fatal error: Argument 2 passed to Microsoft_WindowsAzure_Storage_Table::insertEntity() must be an instance of Microsoft_WindowsAzure_Storage_TableEntity, string given, called in C:\WindowsAzurePHP\InsertEntity.php on line 8 and defined in C:\WindowsAzurePHP\Microsoft\WindowsAzure\Storage\Table.php on line 429" when I try to insert an entity into table storage.

But "Microsoft_WindowsAzure_Storage_TableEntity" is an abstract class.

Coordinator
Sep 21, 2009 at 8:51 AM

Can you post the code that leads to this error?

Sep 21, 2009 at 10:17 AM

Sure, the code is a follows:

<?php
//require_once 'Microsoft/WindowsAzure/Credentials.php'; ***The credentials have been already supplied in the file
//require_once 'Microsoft/WindowsAzure/Storage.php'; ***Already changed from development storage to live storage in the file
require_once 'Microsoft/WindowsAzure/Storage/Table.php';
try
{
 $authenticate = new Microsoft_WindowsAzure_Storage_Table(URL_CLOUD_TABLE, DEVSTORE_ACCOUNT, DEVSTORE_KEY, false, Microsoft_WindowsAzure_RetryPolicy::retryN(10,250));
 $entitytoinsert = $authenticate->insertEntity('sometablename', 'test');
}
catch(Exception $ex)
{
 echo "<b>ERROR : </b>" . $ex->getMessage() . "<br/><br/>";
}
?>

If you are able to insert an entity then can you please send me your code with your account and storage key?

Coordinator
Sep 21, 2009 at 12:14 PM

The second parameter to insertEntity() should not be string. It should be of type Microsoft_WindowsAzure_Storage_TableEntity. Please check http://phpazure.codeplex.com/Wiki/View.aspx?title=Table%20storage&referringTitle=Home for some examples.