Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Php Warning: Mysqli::query Rate Topic   - - - - -

 
  • Blackeye
  • Member
  • Members
  • Join Date: 23-Feb 14
  • 19 posts

Posted 14 November 2017 - 03:20 PM #1

Hi,

I use cs cart 4.1.2

I have these warnings in my error log:

  1. [06-Nov-2017 11:24:36 Europe/Istanbul] PHP Warning:  mysqli::query(): Couldn't fetch mysqli in /home/myusername/public_html/app/Tygh/Backend/Database/Mysqli.php on line 103
  2. [06-Nov-2017 11:24:36 Europe/Istanbul] PHP Warning:  Tygh\Backend\Database\Mysqli::affectedRows(): Property access is not allowed yet in /home/myusername/public_html/app/Tygh/Backend/Database/Mysqli.php on line 156
  3. [06-Nov-2017 11:24:36 Europe/Istanbul] PHP Warning:  Tygh\Backend\Database\Mysqli::errorCode(): Couldn't fetch mysqli in /home/myusername/public_html/app/Tygh/Backend/Database/Mysqli.php on line 174

I asked my hosting company if mysqli is installed in my server and they answered me yes.

 

[root@cpnl ~]# /opt/cpanel/ea-php70/root/usr/bin/php -m | grep mysqli
mysqli
[root@cpnl ~]# /opt/cpanel/ea-php56/root/usr/bin/php -m | grep mysqli
mysqli

 

Is something else that I have to check?

 

Thanks!
 



 
  • The Tool
  • Been Here Way Too Long Member
  • Members
  • Join Date: 30-Mar 07
  • 3,430 posts

Posted 14 November 2017 - 03:51 PM #2

There are a lot of differences between the 4.1.2 and 4.6.3 version of that file including the lines mentioned in your error log.  It may have to do with PHP version compatibility.?

 

/app/Tygh/Backend/Database/Mysqli.php - 4.6.3

<?php
/***************************************************************************
*                                                                          *
*   (c) 2004 Vladimir V. Kalynyak, Alexey V. Vinokurov, Ilya M. Shalnev    *
*                                                                          *
* This  is  commercial  software,  only  users  who have purchased a valid *
* license  and  accept  to the terms of the  License Agreement can install *
* and use this program.                                                    *
*                                                                          *
****************************************************************************
* PLEASE READ THE FULL TEXT  OF THE SOFTWARE  LICENSE   AGREEMENT  IN  THE *
* "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE.            *
****************************************************************************/

namespace Tygh\Backend\Database;

class Mysqli implements IBackend
{
    /**
     * @var \mysqli
     */
    private $conn;

    /**
     * Connects to database server
     * @param  string  $user     user name
     * @param  string  $passwd   password
     * @param  string  $host     server host name
     * @param  string  $database database name
     * @return boolean true on success, false - otherwise
     */
    public function connect($user, $passwd, $host, $database)
    {
        if (!$host || !$user) {
            return false;
        }

        @list($host, $port) = explode(':', $host);

        $this->conn = new \mysqli($host, $user, $passwd, $database, $port);

        if (!empty($this->conn) && empty($this->conn->connect_errno)) {
            return true;
        }

        return false;
    }

    /**
     * Disconnects from the database
     */
    public function disconnect()
    {
        $this->conn->close();
        $this->conn = null;
    }

    /**
     * Changes current database
     * @param  string  $database database name
     * @return boolean true on success, false - otherwise
     */
    public function changeDb($database)
    {
        if ($this->conn->select_db($database)) {
            return true;
        }

        return false;
    }

    /**
     * Queries database
     * @param  string $query SQL query
     * @return query  result
     */
    public function query($query)
    {
        return $this->conn->query($query);
    }

    /**
     * Fetches row from query result set
     * @param  mixed  $result result set
     * @param  string $type   fetch type - 'assoc' or 'indexed'
     * @return array  fetched data
     */
    public function fetchRow($result, $type = 'assoc')
    {
        if ($type == 'assoc') {
            return $result->fetch_assoc();
        } else {
            return $result->fetch_row();
        }
    }

    /**
     * Frees result set
     * @param mixed $result result set
     */
    public function freeResult($result)
    {
        return $result->free();
    }

    /**
     * Return number of rows affected by query
     * @param  mixed $result result set
     * @return int   number of rows
     */
    public function affectedRows($result)
    {
        return $this->conn->affected_rows;
    }

    /**
     * Returns last value of auto increment column
     * @return int value
     */
    public function insertId()
    {
        return $this->conn->insert_id;
    }

    /**
     * Gets last error code
     * @return int error code
     */
    public function errorCode()
    {
        return $this->conn->errno;
    }

    /**
     * Gets last error description
     * @return string error description
     */
    public function error()
    {
        return $this->conn->error;
    }

    /**
     * Escapes value
     * @param  mixed  $value value to escape
     * @return string escaped value
     */
    public function escape($value)
    {
        return $this->conn->real_escape_string($value);
    }

    /**
     * Executes Command after when connecting to MySQL server
     * @param string $command Command to execute
     */
    public function initCommand($command)
    {
        if (!empty($command)) {
            $this->query($command);
            $this->conn->options(MYSQLI_INIT_COMMAND, $command);
        }
    }

    /**
     * @inheritDoc
     */
    public function getVersion()
    {
        return $this->conn->server_version;
    }
}


 
  • Blackeye
  • Member
  • Members
  • Join Date: 23-Feb 14
  • 19 posts

Posted 14 November 2017 - 09:40 PM #3

So, which is the solution? Cs cart version update?



 
  • The Tool
  • Been Here Way Too Long Member
  • Members
  • Join Date: 30-Mar 07
  • 3,430 posts

Posted 15 November 2017 - 12:57 AM #4

Replace the contents of that file with what I posted (save a backup first), and see what happens.  Other than that, yes, update CSC.



 
  • Blackeye
  • Member
  • Members
  • Join Date: 23-Feb 14
  • 19 posts

Posted 15 November 2017 - 12:46 PM #5

Thanks for your help The Tool, I did it and I'll write back to this post for the result of this action.