A PHP Error was encountered Severity: Notice Message: Trying to access array offset on value of type null - codeigniter-3

A PHP Error was encountered
Severity: Notice
Message: Trying to access array offset on value of type null
Filename: datauser/editsuperadmin.php
Line Number: 20
Backtrace:
File: C:\xampp\htdocs\mcicampus2\application\views\Superadmin\datauser\editsuperadmin.php
Line: 20
Function: _error_handler
File: C:\xampp\htdocs\mcicampus2\application\controllers\Superadmin.php
Line: 107
Function: view
File: C:\xampp\htdocs\mcicampus2\index.php
Line: 315
Function: require_once

This error means the index doesn't exist in array. You should use isset before printing or using the value of the array.
To check whether the index exists or not you can use isset():
isset($abc_array['xyz_data']) {
echo $abc_array['xyz_data'];
}

Related

PHP imap library - how to get headers value

I fallow to:
https://github.com/ddeboer/imap/blob/master/src/Message/Headers.php
I try get:
'status' => $message->getHeaders()->get('reply_to'),
But I get issue:
`Severity: Notice
Message: Array to string conversion
Filename: database/DB_driver.php
Line Number: 1471
Error Number: 1054
Unknown column 'Array' in 'field list'
...
..
..
**Array**, 'new')`
How to correct get value reply_to ?
I need to check if this is new message or this is reply on message.

Use of undefined constant APPATH - assumed 'APPATH'

I encounter this Error and i can't Fix it, Someone please help me T_T
A PHP Error was encountered
Severity: Notice
Message: Use of undefined constant APPATH - assumed 'APPATH'
Filename: controllers/Pages.php
Line Number: 4
Backtrace:
File: C:\xampp\htdocs\Project\application\controllers\Pages.php
Line: 4
Function: _error_handler
File: C:\xampp\htdocs\Project\index.php
Line: 315
Function: require_once
and this is my Code
<?php
class Pages extends CI_Controller{
public function view($page = 'home'){
if(!file_exists(APPATH.'views/pages'.$page.'php')){
show_404();
}
$data['title'] = ucfirst($page);
$this->load->view('tenplates/Header');
$this->load->view('pages/'.$page, $data);
$this->load->view('tenplates/Footer');
}
}
When you get a message like...
A PHP Error was encountered
Severity: Notice
Message: Use of undefined constant APPATH - assumed 'APPATH'
Filename: controllers/Pages.php
....
It means the constant, in this case APPATH is not defined. So could be a typo?
If you check out the user guide it states that it is actually APPPATH. A good way to remember it is imagining it as APPlication PATH.
3 "P"'s - not two.
So your code would then become...
<?php
class Pages extends CI_Controller{
public function view($page = 'home'){
if(!file_exists(APPPATH.'views/pages'.$page.'php')){
show_404();
}
$data['title'] = ucfirst($page);
$this->load->view('tenplates/Header');
$this->load->view('pages/'.$page, $data);
$this->load->view('tenplates/Footer');
}
}

Annotating a corpus using Syntaxnet

I am trying to annotate a corpus using Syntaxnet. I added the following lines in the end of the /models/syntaxnet/syntaxnet/models/parsey_mcparseface/context.pbtxt file:
input {
name: 'input_file'
record_format: 'english-text'
Part {
file_pattern: '/home/melvyn/text.txt'
}
}
output {
name: 'output_file'
record_format: 'english-text'
Part {
file_pattern: '/home/melvyn/text-tagged.txt'
}
}
When i run the command:
./demo.sh --input=input_file --output=output_file
I am getting:
./demo.sh: line 31: bazel-bin/syntaxnet/parser_eval: No such file or directory
./demo.sh: line 43: bazel-bin/syntaxnet/parser_eval: No such file or directory
./demo.sh: line 55: bazel-bin/syntaxnet/conll2tree: No such file or directory
According to the answer given ## here ## I changed my demo.sh file and now I get some errors which say:
[libprotobuf ERROR external/tf/google/protobuf/src/google/protobuf/text_format.cc:291] Error parsing text-format syntaxnet.TaskSpec: 200:8: Message type "syntaxnet.TaskOutput" has no field named "Part".
E external/tf/tensorflow/core/framework/op_segment.cc:53] Create kernel failed: Invalid argument: Could not parse task context at syntaxnet/models/parsey_mcparseface/context.pbtxt
E external/tf/tensorflow/core/common_runtime/executor.cc:333] Executor failed to create kernel. Invalid argument: Could not parse task context at syntaxnet/models/parsey_mcparseface/context.pbtxt
[[Node: DocumentSource = DocumentSourcebatch_size=32, corpus_name="stdin-conll", task_context="syntaxnet/models/parsey_mcparseface/context.pbtxt", _device="/job:localhost/replica:0/task:0/cpu:0"]]
What could be a possible solution?
Though it's not certain but I think you are not running the shell script from the root directory. Please try running it as per the instructions mentioned here
I hope it helps.

Magento 1 order creation with disabled produt via soap API

I'm using Magento 1.7 and I want to create an order via magento SOAP API with "disabled" product in it.
Is it possible?
Code:
// create order
echo "\nI will create the order: ";
$resultOrderCreation = $proxy->call($sessionId,"cart.order",array($shoppingCartId, null, $licenseForOrderCreation));
echo "\nOrder created with code:".$resultOrderCreation."\n";
Here is the error trace:
I will create the order:
Fatal error: Uncaught SoapFault exception: [SOAP-ENV:Server] Call to
a member function getId() on a non-object in test2.php:175 Stack
trace:
0 test2.php(175): SoapClient->__call('call', Array)
1 test2.php(175): SoapClient->call('6e2ee08630a720a...', 'cart.order', Array)
2 {main} thrown in test2.php on line 175
You need to change Mage_Sales_Model_Quote_Address_Total_Subtotal::_initItem.
Specifically row with code:
if (!$product || !$product->isVisibleInCatalog()) {
return false;
}
Remove/Customize !$product->isVisibleInCatalog().

Errors in codeigniter-restserver library

I want to use restful in my ci 3.03 application:
I found this tutplus tutorial
I downloaded codeigniter-restserver-master.zip file and copied Format.php and REST_Controller.php(#version 3.0.0) files into /application/libraries/REST directory
I created control application/controllers/api/Users.php :
require_once("application/libraries/REST/REST_Controller.php");
require_once("application/libraries/REST/Format.php");
class Users extends REST_Controller
{
//protected $rest_format = 'json';
function users_get()
{
//$users = $this->user_model->get_all();
$filter_username= $this->get('filter_username');
$filter_user_group= $this->get('filter_user_group');
$filter_active= $this->get('filter_active');
$sort= $this->get('sort');
$sort_direction= $this->get('sort_direction');
//, $filter_user_group, $filter_active, $sort, $sort_direction
$users_list = $this->muser->getUsersList(false, ''/*, $filter_username, $filter_user_group, $filter_active, $sort, $sort_direction, ''*/);
echo '<pre>'.count($users_list).'::$users_lists::'.print_r($users_list,true).'</pre>';
if($users_list)
{
$this->response($users, 200);
}
else
{
$this->response(NULL, 404);
}
}
AND RUNNING URL http://local-ci3.com/api/users I got many errors:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Users::$format
Filename: REST/REST_Controller.php
Line Number: 734
Backtrace:
File: /mnt/diskD_Work/wwwroot/ci3/application/libraries/REST/REST_Controller.php
Line: 734
Function: _error_handler
File: /mnt/diskD_Work/wwwroot/ci3/application/libraries/REST/REST_Controller.php
Line: 649
Function: response
File: /mnt/diskD_Work/wwwroot/ci3/index.php
Line: 292
Function: require_once
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Users::$format
Filename: REST/REST_Controller.php
Line Number: 752
Backtrace:
File: /mnt/diskD_Work/wwwroot/ci3/application/libraries/REST/REST_Controller.php
Line: 752
Function: _error_handler
File: /mnt/diskD_Work/wwwroot/ci3/application/libraries/REST/REST_Controller.php
Line: 649
Function: response
File: /mnt/diskD_Work/wwwroot/ci3/index.php
Line: 292
Function: require_once
Actually I wanted to get some workable library to help me with REST api creation. I think that is preferable way istead of making from zero.
But is this library not workable or does it needs for some fixing? Sorry, what I missed is if this library only for ci 2?
I made search on this forum and found such hint :
I have the same problem when I load both Format.php and
Rest_Controller.php into a controller. After have a quick glance at
Format.php, it appears to be a standalone format conversion helper.
Try to just load Rest_Controller.php and see if your problem goes
away.
I commented line
//require_once("application/libraries/REST/Format.php");
in my controller, but I still get errors like :
Message: Undefined property: Users::$format.
I tried to review code of this library and see that invalid block when data are converted to json format, line 731-757 :
elseif ($data !== NULL)
{
// If the format method exists, call and return the output in that format
if (method_exists($this->format, 'to_' . $this->response->format))
{
// Set the format header
$this->output->set_content_type($this->_supported_formats[$this->response->format], strtolower($this->config->item('charset')));
$output = $this->format->factory($data)->{'to_' . $this->response->format}();
// An array must be parsed as a string, so as not to cause an array to string error
// Json is the most appropriate form for such a datatype
if ($this->response->format === 'array')
{
$output = $this->format->factory($output)->{'to_json'}();
}
}
else
{
// If an array or object, then parse as a json, so as to be a 'string'
if (is_array($data) || is_object($data))
{
$data = $this->format->factory($data)->{'to_json'}();
}
// Format is not supported, so output the raw data as a string
$output = $data;
}
}
If I tried to commented this block, but get error
Message: Array to string conversion
Looks like data are not converted in this case...
Is is possible to fix these errors?
Or can you, please, to tell me advice some codeigniter 3 REST api workable library with similar interface like library above?
Thanks!
I use that lib, work just fine. My suggestion is follow the more relevant installation instruction on github .
you also wrong place the lib file :
Tutorial say :
require(APPPATH'.libraries/REST_Controller.php');
You try :
require_once("application/libraries/REST/REST_Controller.php");
require_once("application/libraries/REST/Format.php");
No need to include the format because on line 407 the lib will load it. And also good to know on line 404 it will load the configuration (application/config/rest.php) it will be your default configuration, and also you can change it to suit your need.
Please let me know if you still got error using my answer :)