php multidimensional SplFixedArray declaration is throwing fatal error - php

I want to declare SplFixedArray(); to save memory consumption. but it is throwing fatal error.
$items=new SplFixedArray();
echo "Array Started...";
for($h=0;$h<5000;$h++)
{
for($i=0;$i<24;$i++)
{
$items[$h][$i]=$objSheet->getCellByColumnAndRow($i,$h+1)->getValue();
}
}
The same is working if do not declare new SplFixedArray();
Error:
Fatal error: Uncaught exception 'RuntimeException' with message 'Index
invalid or out of range' in /home/twa/files.php:168 Stack trace: #0
/home/twa/files.php(168): unknown() #1 {main} thrown in
/home/twa/files.php on line 168
$items=new SplFixedArray(SplFixedArray()); is also failing...
Please let me know correct syntax...

$items = new SplFixedArray(5000);
for ($h=0; $h<5000; $h++) {
$items[$h] = new SplFixedArray(24);
for ($i=0; $i<24; $i++) {
$items[$h][$i] = $objSheet->getCellByColumnAndRow($i,$h+1)->getValue();
}
}

Related

Methods with the same name

My webpage gives the "methods with the same name as their class will not be constructors in a future version of php" error with the below code.
When I change the "function settings()" to "function __construct()", the web page gives a fatal error.
Fatal error: Uncaught Error: Call to undefined method validator::settings() in /home/mertcek1563/public_html/rmd2015/sdwf/validator.php:11
Stack trace:
#0 /home/mertcek1563/public_html/rmd2015/z_common.php(103): validator->__construct()
#1 /home/mertcek1563/public_html/rmd2015/z_core.php(22): include('/home/mertcek15...')
#2 /home/mertcek1563/public_html/rmd2015/index.php(2): include('/home/mertcek15...')
#3 {main}
thrown in /home/mertcek1563/public_html/rmd2015/sdwf/validator.php on line 11
How I can fix this code?
class settings
{
var $settings = array();
function settings(){
$this->settings["price"]=array();
$this->settings["price"]["dot"]=".";
$this->settings["price"]["decimals"]=6;
$this->settings["date"]=array();
$this->settings["date"]["delimiter"]="/";
$this->settings["date"]["format"]="dd/mm/yyyy";
$this->settings["number"]=array();
$this->settings["number"]["dot"]=".";
$this->settings["number"]["decimals"]=6;
}
}
Then I end up with fatal error:
Fatal error: Uncaught Error: Call to undefined method
validator::settings() in
/home/mertcek1563/public_html/rmd2015/sdwf/validator.php:11
<?
include_once("settings.php");
class validator extends settings
{
var $errors = array();
var $required = array();
function __construct(){
$this->settings();
}

php code error in executing

I have been learning php code a few weeks ago. I tried to run a simple code of finding factorial of a number.
The code that I executed first was,
<?php
$sum = 0;
for($i=1;$i<=5;$i++)
{
$sum = $sum + $i;
}
alert("Sum:".$sum);
?>
When I ran this program I got an error showing, alert() as undefined function.
The error,
Fatal error: Uncaught Error: Call to undefined function alert() in C:\xampp\htdocs\SNSFeedbackSystem\factorial.php:7 Stack trace: #0 {main} thrown in C:\xampp\htdocs\SNSFeedbackSystem\factorial.php on line 7
I then realized that alert function should be used in JavaScript, so I changed the alert to echo.
<?php
$sum = 0;
for($i=1;$i<=5;$i++)
{
$sum = $sum + $i;
}
echo "Sum: $sum";
?>
Even after I rectified the error I get the error message, alert() as undefined function
Fatal error: Uncaught Error: Call to undefined function alert() in C:\xampp\htdocs\SNSFeedbackSystem\factorial.php:7 Stack trace: #0 {main} thrown in C:\xampp\htdocs\SNSFeedbackSystem\factorial.php on line 7

SOAP request not working in PHP

We have wsdl :
http://xxxxxxxxxxxxxxx.com/XXXX_Beta_3_API/webservice.asmx?wsdl
IN PHP FILE : i have created a Class with some arrays in it..
class Crmtet {
public $abc;
public $abc2;
public $abc3;
public $abc4;
}
$client = new SoapClient(http://xxxxxxxxxxxxxxx.com/XXXX_Beta_3_API/webservice.asmx?wsdl);
$obj = new Crmtet();
$obj->abc= "Test";
$obj->abc2= "Test2";
$obj->abc3= "Test3";
$obj->abc4= "Test4";
$result = $client->CRM_Warehouse_Master_Insert($obj)->CRM_Warehouse_Master_InsertResult;
echo"re".$result;
But i am getting below error :
Fatal error: Uncaught SoapFault exception: [soap:Server] Server was
unable to process request. ---> Object reference not set to an
instance of an object. in
E:\EasyPHP-12.1\www\test\inserwarrecrm.php:60 Stack trace: #0
E:\EasyPHP-12.1\www\test\inserwarrecrm.php(60):
SoapClient->__call('CRM_Warehouse_M...', Array) #1
E:\EasyPHP-12.1\www\test\inserwarrecrm.php(60):
SoapClient->CRM_Warehouse_Master_Insert(Object(Crmtet)) #2 {main}
thrown in E:\EasyPHP-12.1\www\test\inserwarrecrm.php on line 60
What is the issue.. can anyone help..??

How to fix error returned by __soapCall?

$param['websiteConfigID'] = 729872;
$param['numberOfRecords'] = 10;
$param['numberOfRecords'] = 10;
$client = new SoapClient(WSDL);
$result = $client->__soapCall('GetTicketsStringInputs', array('parameters' => $param));
$result holding this error message....
Fatal error: Uncaught SoapFault exception:
[Client] Function ("GetTicketsStringInputs") is not a valid method for this service in /home/fmticket/public_html/inc/genericLib.php:279
Stack trace:
#0 /home/fmticket/public_html/inc/genericLib.php(279): SoapClient->__soapCall('GetTicketsStrin...', Array)
#1 /home/fmticket/public_html/resultsTicket.php(12): getTickets(Array)
#2 {main} thrown in /home/fmticket/public_html/inc/genericLib.php on line 279
how to resolve it?? plz help.
Your code is calling the remote GetTicketsStringInputs function :
$client->__soapCall('GetTicketsStringInputs', ...
The Fatal error you get indicates :
Function ("GetTicketsStringInputs") is not a valid method for this service
It seems pretty clear : the method you're trying to call doesn't exist, it is not provided by the remote web-service.
So, to fix that Fatal Error, you have to stop calling that function ;-)
You should check the WSDL of your webservice : does it really export such a method ?

PHP spl_autoload_register() doesn't find function

This code:
<?php
namespace designblob;
function autoloader($class){
include "wrappers/databaseWrapper.php";
}
spl_autoload_register('autoloader');
?>
throws this error:
Fatal error: Uncaught exception 'LogicException' with message 'Function 'autoloader' not found (function 'autoloader' not found or invalid function name)' in /var/www/xxx/library/autoloader.php:8 Stack trace: #0 /var/www/xxx/library/autoloader.php(8): spl_autoload_register('autoloader') #1 /var/www/xxx/library/debug.php(19): require_once('/var/www/xxx...') #2 {main} thrown in /var/www/xxxm/library/autoloader.php on line 8
Why doesn't it work?
spl_autoload_register('designblob\autoloader');

Categories