You are here:  » can't add new field to database table - dbmod Fatal error

Active Forum Topics


can't add new field to database table - dbmod Fatal error

Submitted by atar2 on Fri, 2021-11-26 09:59 in

Hello,
fresh install last version yesterday went fine.
then I tried to add a field "brand_url" and create this php file:

<?php
  
require("includes/common.php");
  
$sql "ALTER TABLE `".$config_databaseTablePrefix."feeds`
            ADD `field_brand_url` VARCHAR(255) NOT NULL default ''"
;
  
database_queryModify($sql,$result);
  
$sql "ALTER TABLE `".$config_databaseTablePrefix."products`
            ADD `brand_url` VARCHAR(255) NOT NULL default ''"
;
  
database_queryModify($sql,$result);
  print 
"Done.";
?>

then i browse to https://myDomain/myFolder/dbmod-product_url.php
and receive this error message:
Fatal error: require(): Failed opening required 'includes/common.php' (include_path='.:/usr/local/php74/pear') in /home/customer/www/myDomain/public_html/myFolder/dbmod-brand_url.php on line 2

i read here https://www.pricetapestry.org/node/484
and replace includes/common.php from if (file_exists("config.php")) to if (@fopen("config.php","r")) but same issue

Thank you,
Uri

Submitted by support on Fri, 2021-11-26 10:17

Hi,

That's strange -

  require("includes/common.php");

...is correct for running a dbmod script in the top level folder of a Price Tapestry installation (you will see the same line at the top of pretty much every file). Try making a version to run in the /admin/ folder instead and change the above line to:

  require("../includes/common.php");

Cheers,
David.
--
PriceTapestry.com

Submitted by atar2 on Fri, 2021-11-26 12:23

Thank you David for your very quick reply.

now all OK.

{code saved}

anyway, you helped me and now all ok.

Uri