Post by webservsol » Wed Jul 18, 2018 7:43 am

I have a RestAPI for Opencart 1.5.2.1 running on PHP7 (PHP-FPM). When I try to call one of the functions I get an error message:
<b>Notice</b>: Error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1
<br />Error No: 1064
<br />SELECT wishlist FROM customer WHERE customer_id = in
<b>/home/onusapp/ocart.onusapp.com/system/database/mysqliz.php</b> on line
<b>53</b>
After investigation I found the error code:

Code: Select all

	public function getDBWishlist() {

		if (version_compare(VERSION,'2.1.0.0','>=')) {
			$this->load->model('account/wishlist');
			$result = $this->model_account_wishlist->getWishlist();
			return $result;
		} else {
			$query = $this->db->query("SELECT wishlist FROM ". DB_PREFIX ."customer WHERE customer_id = ". $this->customer->getId())->row;
			return unserialize($query['wishlist']);
		}
	}
I tried adding colons to the code didn't resolve the issue, any help please!

Newbie

Posts

Joined
Mon Jan 30, 2012 9:49 am

Post by kestas » Wed Jul 18, 2018 3:17 pm

Hi,
try this query:

Code: Select all

$query = $this->db->query("SELECT wishlist FROM `" .  DB_PREFIX  . "customer` WHERE `customer_id` = '" .  $this->customer->getId() .  "'")->row;

Custom OpenCart modules and solutions. Just PM me... Extensions you can find here and here


Active Member

Posts

Joined
Tue Oct 12, 2010 2:23 am

Post by webservsol » Thu Jul 19, 2018 5:27 am

Hi,

Thanks for the code, I've tried this code and returned with 2 new errors unfortunately.
<b>Notice</b>: Undefined index: wishlist in
<b>/home/user/subdomain.com/catalog/model/irestapi/catalog.php</b> on line
<b>1731</b>
<b>Warning</b>: Invalid argument supplied for foreach() in
<b>/home/user/subdomain.com/catalog/model/irestapi/catalog.php</b> on line
<b>2049</b>
<b>Notice</b>: Undefined index: bottom in
<b>/home/user/subdomain.com/catalog/model/irestapi/catalog.php</b> on line
<b>2329</b>
I'm gonna share the codes with the lines number

Code: Select all

1722	public function getDBWishlist() {
1723
1724		if (version_compare(VERSION,'2.1.0.0','>=')) {
1725			$this->load->model('account/wishlist');
1726			$result = $this->model_account_wishlist->getWishlist();
1727			return $result;
1728		} else {
1729			//$query = $this->db->query("SELECT wishlist FROM ". DB_PREFIX ."customer WHERE customer_id = ". $this->customer->getId())->row;
1730			$query = $this->db->query("SELECT wishlist FROM `" .  DB_PREFIX  . "customer` WHERE `customer_id` = '" .  $this->customer->getId() .  "'")->row;
1731			return unserialize($query['wishlist']);
1732		}
1733	}

Code: Select all

2049			foreach($this->getDBWishlist() as [highlight]$wishlist[/highlight]) {
2050				if($wishlist['product_id'] == $result['product_id']){
2051					$already_status = true;
2052				}
2053			}

Newbie

Posts

Joined
Mon Jan 30, 2012 9:49 am

Post by kestas » Thu Jul 19, 2018 6:55 am

Hi,
Seems you use extension with a lot of bugs. You should ask developer of this module first. Did you?

Custom OpenCart modules and solutions. Just PM me... Extensions you can find here and here


Active Member

Posts

Joined
Tue Oct 12, 2010 2:23 am
Who is online

Users browsing this forum: No registered users and 6 guests