getting an error PHP Warning: Illegal string offset 'error' in ../roundcube/plugins/vtrc/vtwsclib/Vtiger/WSClient.php on line 93
function in php file (line 93 ends)
function hasError($result) {
if(isset($result[success]) && $result[success] === true) {
$this->_lasterror = false;
return false;
}
$this->_lasterror = $result[error];
return true;
You have two IMPORTANT errors!!
First of all : You need to use ' OR " to get the value of an Array
$value = $array["KEY_HERE"];
Same as
$value = $array['KEY_HERE'];
PHP is friendly with quotes =)
Second : You need to check if "error" Key exists in Array $result like as "success"
function hasError($result) {
if(isset($result["success"]) && $result["success"] === true) {
... CODE ...
}
if(isset($result["error"])) {
... CODE ...
}
... REST OF METHOD ...
}
What does it mean "Illegal string offset 'error'? Exactly that not exists Index 'error' for Array $result. Please be careful, because the script had tried to access in a memory piece that is not declared (initialized - set) for this array. It's dangerous !!
$myArray = array(); /** Empty array **/
$myArray["error"] = ""; /** set index "error" with "" value **/
echo isset($myArray["error"]); /** echo TRUE **/
echo isset($myArray["success"]); /** echo FALSE **/
echo $myArray["success"]; /** throw exception "Illegal string offset 'success' ..." because not set in Array **/