0

I'm attempting to use a PDO Database class written by someone else for php.

The entire class can be found at the following link: HERE

One of the methods in the class produces a PHP parse error.

Here is the method causing the error

public function bind($para, $value)
{
    $this->parameters[sizeof($this->parameters)] = [":" . $para , $value];
}

The error that I'm receiving is:

PHP Parse error: syntax error, unexpected '['

By removing parts of the one statement in the method I've determined that the second "[' the one after the equals sign is the one that's causing the problem.

My google fu hasn't been able to find any statements with regard to PDO parameters that resemble this statement for me to figure out what is wrong (or even what is right) with the statement.

I'm new to PDO and I don't understand the statement enough to see how to fix it. Any help would be greatly appreciated.

Caveman
  • 423
  • 1
  • 4
  • 9
  • 2
    Are you using PHP < 5.4? http://stackoverflow.com/questions/18050071/php-parse-syntax-errors-and-how-to-solve-them/29505827#29505827 – chris85 Mar 12 '16 at 19:25
  • 1
    @Anant think you need `array` before the `(`. – chris85 Mar 12 '16 at 19:32
  • `$this->parameters(sizeof($this->parameters)) = array(":" .$para , $value);` – Alive to die - Anant Mar 12 '16 at 19:47
  • I'm running php 5.3.3. I made the changes suggested by Anant. I'm getting a new error now. PHP Fatal error: Can't use method return value in write context. I'll research that error and see what I can find. – Caveman Mar 15 '16 at 18:02
  • Ok, i got the parsing errors straightened out (don't know about runtime errors yet thought). Anant almost had it correct. The correct statement Is :$this->parameters[sizeof($this->parameters)] = array(":" . $para , $value); @Anant if you post that as an answer to the question I'll mark it as the solution. Thanks for your help. – Caveman Mar 15 '16 at 20:14
  • Sorry i can't put an answer. Your question is closed. – Alive to die - Anant Mar 15 '16 at 20:19

0 Answers0