Nazly
Nazly

Reputation: 65

Fatal error : Cannot use [] for reading

I used implode in my request SQL, for a checkBox for multiple choice.

if ($this->_count == 0) {
    $this->_sqlWhere.="`piecearticles`.`ID_Article`=`article`.`ID_Article` AND `piecearticles`.`Designiation`=`article`.`Designiation` AND `article`.`ID_LRU`=`lru`.`ID_LRU` AND lru.LRU IN (" . implode(",", $this->_lru[]) . ")"; 
    $this->_count++;
}

When I run it return an error:

Fatal error: Cannot use [] for reading

Is't the implode a cause to this error or in my request ?

Upvotes: 0

Views: 2068

Answers (1)

Tom
Tom

Reputation: 4292

The error is what the error says - you can't use [] when you're trying to read an array. You can do;

implode(",", $this->_lru)

Or

implode(",", array("a2", "b"))

You only use the square brackets when you want to write into an array.

Upvotes: 2

Related Questions