Jump to content

Please Help Echoing Constant


lingo5

Recommended Posts

hi, I have the PHP code below wher I'm trying to echo the contant CNT_TXT_EMPTYMESSAGE.

i have trie everything...with double quotes...single...with nothing...everything but nothing seems to work.

Am i using the correct syntax to do this?

Many thanks

 

<?php

include_once('config.php');
if (!$config['currencyCode']) $config['currencyCode']					 = 'EUR';
if (!$config['text']['cartTitle']) $config['text']['cartTitle']		 = 'Shopping Cart';
if (!$config['text']['singleItem']) $config['text']['singleItem']		 = 'Item';
if (!$config['text']['multipleItems']) $config['text']['multipleItems'] = 'Items';
if (!$config['text']['subtotal']) $config['text']['subtotal']			 = 'Subtotal';
if (!$config['text']['update']) $config['text']['update']				 = 'update';
if (!$config['text']['checkout']) $config['text']['checkout']			 = 'checkout';
if (!$config['text']['checkoutPaypal']) $config['text']['checkoutPaypal'] = 'Checkout with PayPal';
if (!$config['text']['removeLink']) $config['text']['removeLink']		 = 'remove';
if (!$config['text']['emptyButton']) $config['text']['emptyButton']	 = 'empty';
if (!$config['text']['emptyMessage']) $config['text']['emptyMessage']	 = '.CNT_TXT_EMPTYMESSAGE.';
if (!$config['text']['itemAdded']) $config['text']['itemAdded']		 = 'Item added!';
if (!$config['text']['priceError']) $config['text']['priceError']		 = 'Invalid price format!';
if (!$config['text']['quantityError']) $config['text']['quantityError'] = 'Item quantities must be whole numbers!';
if (!$config['text']['checkoutError']) $config['text']['checkoutError'] = 'Your order could not be processed!';
if ($_GET['ajax'] == 'true') {
header('Content-type: application/json; charset=utf-8');
echo json_encode($config);
}
?>

Edited by lingo5
Link to comment
Share on other sites

I remember you :)

 

Why are you using single quotes around it, in the very first post ?

 

PS: It should be,

if (!$config['text']['emptyMessage']) $config['text']['emptyMessage']    = CNT_TXT_EMPTYMESSAGE;

Edited by jazzman1
Link to comment
Share on other sites

The correct syntax is -

 

if (!$config['text']['emptyMessage']) $config['text']['emptyMessage'] = CNT_TXT_EMPTYMESSAGE;

 

Edit: seems to be an echo in here..............

Edited by PFMaBiSmAd
never mind the forum's post notification fails again.
Link to comment
Share on other sites

weird...

i was including the php file where all my constants are defined at the top of each page like so:

 

include ('../constants.php');

 

I have changed this to

 

include ('constants.php');

 

..and it works now !!!. How come....my constants.php file is one dir up...

Link to comment
Share on other sites

No, that's no possible! You have to have a constants.php file in the same directory or you are handling a different file or you have more including files.

Copy/paste this code to check where are you..

echo dirname(__FILE__);

Edited by jazzman1
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.