MySQL_query problem?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
jayson.ph
Forum Contributor
Posts: 165
Joined: Mon Jan 02, 2012 9:20 am
Location: MP
Contact:

MySQL_query problem?

Post by jayson.ph »

Hi all.

can i have a favor to help to recognized the problem below. i was stop from this in just 1 week for this error,

Code: Select all

public function	ExecuteS($query, $array = true, $use_cache = 1)
	{
		$this->_result = false;
		$this->_lastQuery = $query;
		if ($use_cache AND _PS_CACHE_ENABLED_)
			if ($array AND ($result = Cache::getInstance()->get(md5($query))))
			{
				$this->_lastCached = true;
				return $result;
			}
>>>>>>>>>>>>>>>		if ($this->_link && $this->_result = mysql_query($query, $this->_link))[/color]
		{
			$this->_lastCached = false;
			if (_PS_DEBUG_SQL_)
				$this->displayMySQLError($query);
			if (!$array)
				return $this->_result;
			$resultArray = array();
			// Only SELECT queries and a few others return a valid resource usable with mysql_fetch_assoc
			if ($this->_result !== true)
				while ($row = mysql_fetch_assoc($this->_result))
					$resultArray[] = $row;
			if ($use_cache AND _PS_CACHE_ENABLED_)	
				Cache::getInstance()->setQuery($query, $resultArray);
			return $resultArray;
		}
		if (_PS_DEBUG_SQL_)
			$this->displayMySQLError($query);
		return false;
	}

	public function nextRow($result = false)
	{
		return mysql_fetch_assoc($result ? $result : $this->_result);
	}
	
	public function	delete($table, $where = false, $limit = false, $use_cache = 1)
	{
		$this->_result = false;
		if ($this->_link)
		{
			$query  = 'DELETE FROM `'.pSQL($table).'`'.($where ? ' WHERE '.$where : '').($limit ? ' LIMIT '.(int)($limit) : '');
			$res =  mysql_query($query, $this->_link);
			if ($use_cache AND _PS_CACHE_ENABLED_)
				Cache::getInstance()->deleteQuery($query);
			return $res;
		}
			
		return false;
	}
	
	public function	NumRows()
	{
		if (!$this->_lastCached AND $this->_link AND $this->_result)
		{
			$nrows = mysql_num_rows($this->_result);
			if (_PS_CACHE_ENABLED_)
				Cache::getInstance()->setNumRows(md5($this->_lastQuery), $nrows);
			return $nrows;
		}
		elseif (_PS_CACHE_ENABLED_ AND $this->_lastCached)
		{
			return Cache::getInstance()->getNumRows(md5($this->_lastQuery));
		}
	}
	
	public function	Insert_ID()
	{
		if ($this->_link)
			return mysql_insert_id($this->_link);
		return false;
	}
	
	public function	Affected_Rows()
	{
		if ($this->_link)
			return mysql_affected_rows($this->_link);
		return false;
	}

	protected function q($query, $use_cache = 1)
	{
		global $webservice_call;
		$this->_result = false;
		if ($this->_link)
		{
			$result =  mysql_query($query, $this->_link);
			$this->_lastQuery = $query;
			if ($webservice_call)
				$this->displayMySQLError($query);
			if ($use_cache AND _PS_CACHE_ENABLED_)
				Cache::getInstance()->deleteQuery($query);
			return $result;
		}
		return false;
	}
	
here is the error message, : Warning: mysql_query() [function.mysql-query]: Unable to save result set in /home/octagon/public_html/classes/MySQL.php on line 145.

Thank very much.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: MySQL_query problem?

Post by requinix »

Some quick Googling (I suggest you try it) mentions possible corruption with MySQL data files.

From a command line try running

Code: Select all

$ myisamchk -r /var/lib/mysql/database/*.MYI
replacing /var/lib/mysql with the path to your MySQL's data files.
User avatar
jayson.ph
Forum Contributor
Posts: 165
Joined: Mon Jan 02, 2012 9:20 am
Location: MP
Contact:

Re: MySQL_query problem?

Post by jayson.ph »

How ? and where i can put the code/ file path ?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: MySQL_query problem?

Post by requinix »

Who maintains your database?
User avatar
jayson.ph
Forum Contributor
Posts: 165
Joined: Mon Jan 02, 2012 9:20 am
Location: MP
Contact:

Re: MySQL_query problem?

Post by jayson.ph »

actually, i am the admin but. ah, i am new for this.. i mean, im not familiar the tool they use, they use prestashop". an for now im lost and moving to keep familiar... the is octagon.com.ph, please take a look, there are a lot problem.

Thanks
User avatar
theserve
Forum Newbie
Posts: 24
Joined: Wed Jan 18, 2012 6:35 am
Location: London

Re: MySQL_query problem?

Post by theserve »

you need to logon to the command line via ssh to run myisamchk. That is of course if your database is using the MyISAM storage engine.
User avatar
jayson.ph
Forum Contributor
Posts: 165
Joined: Mon Jan 02, 2012 9:20 am
Location: MP
Contact:

Re: MySQL_query problem?

Post by jayson.ph »

God im bleeding here.. and how do i find the command line for the ssh?
Post Reply