1
votes

Having issues with the following and I have not found an answer that would fit in yet...

Strict Standards: Only variables should be passed by reference in ... Code is : public function query($query) {

    mysql_query('SET NAMES \'utf8\'', $this->connection);

    $result = mysql_query($query, $this->connection);
    $this->counter++;

    if (!$result) {
        throw new Exception('A MySQL error (#' . mysql_errno() . ' / ' . mysql_error() . ') occured in the following query: \'' . $this->parseQuery($query) . '\'');
    }

    if (in_array(strtoupper(array_shift(explode(' ', $this->parseQuery($query)))), array('SELECT', 'SHOW', 'EXPLAIN', 'DESCRIBE'))) 
    {
       $this->queries[] = $result;
    } 

Problem is in this part : if (in_array(strtoupper(array_shift(explode(' ', $this->parseQuery($query)))), array('SELECT', 'SHOW', 'EXPLAIN', 'DESCRIBE')))

I tried to rewrite so it is not "nested"anymore...but no luck. I could use some help on this as my programming skills are not good enough

2

2 Answers

1
votes

It's in array_shift it only accepts variable reference:

$arr = explode(' ', $this->parseQuery($query));

if (in_array(strtoupper(array_shift($arr)), array('SELECT', 'SHOW', 'EXPLAIN', 'DESCRIBE'))) 
{
    $this->queries[] = $result;
}

This will work

1
votes

try this :

<?php
    mysql_query('SET NAMES \'utf8\'', $this->connection);

    $result = mysql_query($query, $this->connection);
    $this->counter++;

    if (!$result) {
        throw new Exception('A MySQL error (#' . mysql_errno() . ' / ' . mysql_error() . ') occured in the following query: \'' . $this->parseQuery($query) . '\'');
    }
    $arr = array_shift(explode(' ', $this->parseQuery($query)));
    if (in_array(strtoupper($arr), array('SELECT', 'SHOW', 'EXPLAIN', 'DESCRIBE'))) 
    {
       $this->queries[] = $result;
    }