You are here:  » Getting database.php errors in log


Getting database.php errors in log

Submitted by Retro135 on Wed, 2015-07-08 10:58 in

for lines 38 & 43:
PHP Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /my-home-path/shops/includes/database.php on line 38, referer:

PHP Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in /my-home-path/shops/includes/database.php on line 43, referer:

Dozens of errors, referer is everything and anything: merchants, brand, feeds_register_step2.php, etc.

Can you help with this?

Submitted by support on Wed, 2015-07-08 12:49

Hi,

That's strange - database errors are most likely to occur when adding custom fields but without completing the necessary database modifications however that is normally restricted to importing.

However, you should be able to see the cause by enabling database debug mode by changing line 6 in config.advanced.php as follows;

  $config_databaseDebugMode = TRUE:

With that in place, go through the registration process for a feed and the actual MySQL error message should be displayed when it occurs during Step 2. If you're not sure from the output displayed where the problem lies, or if it doesn't occur at that point of course, let me know what if anything is displayed and I'll check it out further with you;

Cheers,
David.
--
PriceTapestry.com

Submitted by Retro135 on Wed, 2015-07-08 18:52

The errors display when I click on Merchant, Category or Brand: {link saved}
Here's 3 messages that appear, for example:

[SELECT DISTINCT(categoryid) FROM `pt_products` WHERE brand = 'Wedding Belle Favors' AND categoryid > 0][Unknown column 'categoryid' in 'field list']

[SELECT DISTINCT(merchant) FROM `pt_products` WHERE categoryid = '1' ORDER BY merchant][Unknown column 'categoryid' in 'where clause'][SELECT DISTINCT(brand) FROM `pt_products` WHERE categoryid = '1' AND brand <> '' ORDER BY brand][Unknown column 'categoryid' in 'where clause']

[SELECT DISTINCT(categoryid) FROM `pt_products` WHERE merchant = 'Precious Moments' AND categoryid > 0][Unknown column 'categoryid' in 'field list']

Don't know what to do to resolve this.

Submitted by support on Wed, 2015-07-08 19:08

Hi,

The error and confusion about categories are related, all it is, I realise now as you mentioned returning to an earlier installation and it sounds like you have installed the latest distribution over the top, so the database schema isn't quite in sync - specifically, the missing `categoryid` field on the pt_products table added for the Category Hierarchy support of the latest distribution.

To create this field, and its corresponding index, create a dbmod.php script as follows, and run once from the top level folder of your Price Tapestry installation:

<?php
  
require("includes/common.php");
  
$sql "ALTER TABLE `".$config_databaseTablePrefix."products` ADD categoryid int(11) NOT NULL default '0'";
  
database_queryModify($sql,$result);
  
$sql "CREATE INDEX categoryid ON `".$config_databaseTablePrefix."products` (categoryid)";
  
database_queryModify($sql,$result);
  print 
"Done.";
?>

Also however, it implies that the option to use Category Hierarchy is enabled, so until you wish to set this up, this option should be disabled by reverting line 92 of config.advanced.php as follows:

  $config_useCategoryHierarchy = FALSE;

Cheers,
David.
--
PriceTapestry.com

Submitted by Retro135 on Thu, 2015-07-16 15:12

All good, thank you again, David! No more errors.