Page 1 of 1

SyntaxError & The Find Code (Solved)

Posted: Mon Nov 05, 2012 3:56 am
by allaroundfem
Hello, I was hoping a wiz could shine some light on the following error when I go to account/register. I know that it is cause by the last piece of code added to my root index file, it is my site verification for 'the find' search site. When I delete the code, it works fine. Any ideas on ways around this?

I am using version 1.5.4.1

web address: http://www.allaroundfem.com

Thanks in advance,
Kristi

Code: Select all

SyntaxError: JSON.parse: unexpected non-whitespace character after JSON data

OK


{"country_id":"223","name":"United States","iso_code_2":"US","iso_code_3":"USA","address_format":"{firstname} {lastname}\r\n{company}\r\n{address_1}\r\n{address_2}\r\n{city}, {zone} {postcode}\r\n{country}","postcode_required":"0","zone":[{"zone_id":"3613","country_id":"223","name":"Alabama","code":"AL","status":"1"},{"zone_id":"3614","country_id":"223","name":"Alaska","code":"AK","status":"1"},{"zone_id":"3615","country_id":"223","name":"American Samoa","code":"AS","status":"1"},{"zone_id":"3616","country_id":"223","name":"Arizona","code":"AZ","status":"1"},{"zone_id":"3617","country_id":"223","name":"Arkansas","code":"AR","status":"1"},{"zone_id":"3618","country_id":"223","name":"Armed Forces Africa","code":"AF","status":"1"},{"zone_id":"3619","country_id":"223","name":"Armed Forces Americas","code":"AA","status":"1"},{"zone_id":"3620","country_id":"223","name":"Armed Forces Canada","code":"AC","status":"1"},{"zone_id":"3621","country_id":"223","name":"Armed Forces Europe","code":"AE","status":"1"},{"zone_id":"3622","country_id":"223","name":"Armed Forces Middle East","code":"AM","status":"1"},{"zone_id":"3623","country_id":"223","name":"Armed Forces Pacific","code":"AP","status":"1"},{"zone_id":"3624","country_id":"223","name":"California","code":"CA","status":"1"},{"zone_id":"3625","country_id":"223","name":"Colorado","code":"CO","status":"1"},{"zone_id":"3626","country_id":"223","name":"Connecticut","code":"CT","status":"1"},{"zone_id":"3627","country_id":"223","name":"Delaware","code":"DE","status":"1"},{"zone_id":"3628","country_id":"223","name":"District of Columbia","code":"DC","status":"1"},{"zone_id":"3629","country_id":"223","name":"Federated States Of Micronesia","code":"FM","status":"1"},{"zone_id":"3630","country_id":"223","name":"Florida","code":"FL","status":"1"},{"zone_id":"3631","country_id":"223","name":"Georgia","code":"GA","status":"1"},{"zone_id":"3632","country_id":"223","name":"Guam","code":"GU","status":"1"},{"zone_id":"3633","country_id":"223","name":"Hawaii","code":"HI","status":"1"},{"zone_id":"3634","country_id":"223","name":"Idaho","code":"ID","status":"1"},{"zone_id":"3635","country_id":"223","name":"Illinois","code":"IL","status":"1"},{"zone_id":"3636","country_id":"223","name":"Indiana","code":"IN","status":"1"},{"zone_id":"3637","country_id":"223","name":"Iowa","code":"IA","status":"1"},{"zone_id":"3638","country_id":"223","name":"Kansas","code":"KS","status":"1"},{"zone_id":"3639","country_id":"223","name":"Kentucky","code":"KY","status":"1"},{"zone_id":"3640","country_id":"223","name":"Louisiana","code":"LA","status":"1"},{"zone_id":"3641","country_id":"223","name":"Maine","code":"ME","status":"1"},{"zone_id":"3642","country_id":"223","name":"Marshall Islands","code":"MH","status":"1"},{"zone_id":"3643","country_id":"223","name":"Maryland","code":"MD","status":"1"},{"zone_id":"3644","country_id":"223","name":"Massachusetts","code":"MA","status":"1"},{"zone_id":"3645","country_id":"223","name":"Michigan","code":"MI","status":"1"},{"zone_id":"3646","country_id":"223","name":"Minnesota","code":"MN","status":"1"},{"zone_id":"3647","country_id":"223","name":"Mississippi","code":"MS","status":"1"},{"zone_id":"3648","country_id":"223","name":"Missouri","code":"MO","status":"1"},{"zone_id":"3649","country_id":"223","name":"Montana","code":"MT","status":"1"},{"zone_id":"3650","country_id":"223","name":"Nebraska","code":"NE","status":"1"},{"zone_id":"3651","country_id":"223","name":"Nevada","code":"NV","status":"1"},{"zone_id":"3652","country_id":"223","name":"New Hampshire","code":"NH","status":"1"},{"zone_id":"3653","country_id":"223","name":"New Jersey","code":"NJ","status":"1"},{"zone_id":"3654","country_id":"223","name":"New Mexico","code":"NM","status":"1"},{"zone_id":"3655","country_id":"223","name":"New York","code":"NY","status":"1"},{"zone_id":"3656","country_id":"223","name":"North Carolina","code":"NC","status":"1"},{"zone_id":"3657","country_id":"223","name":"North Dakota","code":"ND","status":"1"},{"zone_id":"3658","country_id":"223","name":"Northern Mariana Islands","code":"MP","status":"1"},{"zone_id":"3659","country_id":"223","name":"Ohio","code":"OH","status":"1"},{"zone_id":"3660","country_id":"223","name":"Oklahoma","code":"OK","status":"1"},{"zone_id":"3661","country_id":"223","name":"Oregon","code":"OR","status":"1"},{"zone_id":"3662","country_id":"223","name":"Palau","code":"PW","status":"1"},{"zone_id":"3663","country_id":"223","name":"Pennsylvania","code":"PA","status":"1"},{"zone_id":"3664","country_id":"223","name":"Puerto Rico","code":"PR","status":"1"},{"zone_id":"3665","country_id":"223","name":"Rhode Island","code":"RI","status":"1"},{"zone_id":"3666","country_id":"223","name":"South Carolina","code":"SC","status":"1"},{"zone_id":"3667","country_id":"223","name":"South Dakota","code":"SD","status":"1"},{"zone_id":"3668","country_id":"223","name":"Tennessee","code":"TN","status":"1"},{"zone_id":"3669","country_id":"223","name":"Texas","code":"TX","status":"1"},{"zone_id":"3670","country_id":"223","name":"Utah","code":"UT","status":"1"},{"zone_id":"3671","country_id":"223","name":"Vermont","code":"VT","status":"1"},{"zone_id":"3672","country_id":"223","name":"Virgin Islands","code":"VI","status":"1"},{"zone_id":"3673","country_id":"223","name":"Virginia","code":"VA","status":"1"},{"zone_id":"3674","country_id":"223","name":"Washington","code":"WA","status":"1"},{"zone_id":"3675","country_id":"223","name":"West Virginia","code":"WV","status":"1"},{"zone_id":"3676","country_id":"223","name":"Wisconsin","code":"WI","status":"1"},{"zone_id":"3677","country_id":"223","name":"Wyoming","code":"WY","status":"1"}],"status":"1"}<a class="tf_upfront_badge" href="http://www.thefind.com/store/about-x11sorg" title="TheFind Upfront"><img  border="0" src="//upfront.thefind.com/images/badges/r/c0/65/c065f44ffae9f89732ba55b6a33e3aaf.png" alt="All Around Fem is an Upfront Merchant on TheFind. Click for info."/></a>
  <script type="text/javascript">
    (function() {
      var upfront = document.createElement('SCRIPT'); upfront.type = "text/javascript"; upfront.async = true;
      upfront.src = document.location.protocol + "//upfront.thefind.com/scripts/main/utils-init-ajaxlib/upfront-badgeinit.js";
      upfront.text = "thefind.upfront.init('tf_upfront_badge', 'c065f44ffae9f89732ba55b6a33e3aaf')";
      document.getElementsByTagName('HEAD')[0].appendChild(upfront);
    })();
  </script>

Re: SyntaxError & The Find Code

Posted: Mon Nov 05, 2012 12:17 pm
by Avvici
Your Json output is invalid. These errors can be caused by a missing coma, to echoing the json data on the wrong side of the "loop". How about also at the very least paste us the code in your index file.

Re: SyntaxError & The Find Code

Posted: Tue Nov 06, 2012 1:28 pm
by allaroundfem
Thanks so much fro the reply. That seems like the issue but I have no idea where. Here's the code.

Code: Select all

<?php
// Version
define('VERSION', '1.5.4');

// Configuration
require_once('config.php');
   
// Install 
if (!defined('DIR_APPLICATION')) {
	header('Location: install/index.php');
	exit;
}

// Startup
require_once(DIR_SYSTEM . 'startup.php');

// Application Classes
require_once(DIR_SYSTEM . 'library/customer.php');
require_once(DIR_SYSTEM . 'library/affiliate.php');
require_once(DIR_SYSTEM . 'library/currency.php');
require_once(DIR_SYSTEM . 'library/tax.php');
require_once(DIR_SYSTEM . 'library/weight.php');
require_once(DIR_SYSTEM . 'library/length.php');
require_once(DIR_SYSTEM . 'library/cart.php');

// Registry
$registry = new Registry();

// Loader
$loader = new Loader($registry);
$registry->set('load', $loader);

// Config
$config = new Config();
$registry->set('config', $config);

// Database 
$db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
$registry->set('db', $db);

// Store
if (isset($_SERVER['HTTPS']) && (($_SERVER['HTTPS'] == 'on') || ($_SERVER['HTTPS'] == '1'))) {
	$store_query = $db->query("SELECT * FROM " . DB_PREFIX . "store WHERE REPLACE(`ssl`, 'www.', '') = '" . $db->escape('https://' . str_replace('www.', '', $_SERVER['HTTP_HOST']) . rtrim(dirname($_SERVER['PHP_SELF']), '/.\\') . '/') . "'");
} else {
	$store_query = $db->query("SELECT * FROM " . DB_PREFIX . "store WHERE REPLACE(`url`, 'www.', '') = '" . $db->escape('http://' . str_replace('www.', '', $_SERVER['HTTP_HOST']) . rtrim(dirname($_SERVER['PHP_SELF']), '/.\\') . '/') . "'");
}

if ($store_query->num_rows) {
	$config->set('config_store_id', $store_query->row['store_id']);
} else {
	$config->set('config_store_id', 0);
}
		
// Settings
$query = $db->query("SELECT * FROM " . DB_PREFIX . "setting WHERE store_id = '0' OR store_id = '" . (int)$config->get('config_store_id') . "' ORDER BY store_id ASC");

foreach ($query->rows as $setting) {
	if (!$setting['serialized']) {
		$config->set($setting['key'], $setting['value']);
	} else {
		$config->set($setting['key'], unserialize($setting['value']));
	}
}

if (!$store_query->num_rows) {
	$config->set('config_url', HTTP_SERVER);
	$config->set('config_ssl', HTTPS_SERVER);	
}

// Url
$url = new Url($config->get('config_url'), $config->get('config_use_ssl') ? $config->get('config_ssl') : $config->get('config_url'));	
$registry->set('url', $url);

// Log 
$log = new Log($config->get('config_error_filename'));
$registry->set('log', $log);

function error_handler($errno, $errstr, $errfile, $errline) {
	global $log, $config;
	
	switch ($errno) {
		case E_NOTICE:
		case E_USER_NOTICE:
			$error = 'Notice';
			break;
		case E_WARNING:
		case E_USER_WARNING:
			$error = 'Warning';
			break;
		case E_ERROR:
		case E_USER_ERROR:
			$error = 'Fatal Error';
			break;
		default:
			$error = 'Unknown';
			break;
	}
		
	if ($config->get('config_error_display')) {
		echo '<b>' . $error . '</b>: ' . $errstr . ' in <b>' . $errfile . '</b> on line <b>' . $errline . '</b>';
	}
	
	if ($config->get('config_error_log')) {
		$log->write('PHP ' . $error . ':  ' . $errstr . ' in ' . $errfile . ' on line ' . $errline);
	}

	return true;
}
	
// Error Handler
set_error_handler('error_handler');

// Request
$request = new Request();
$registry->set('request', $request);
 
// Response
$response = new Response();
$response->addHeader('Content-Type: text/html; charset=utf-8');
$response->setCompression($config->get('config_compression'));
$registry->set('response', $response); 
		
// Cache
$cache = new Cache();
$registry->set('cache', $cache); 

// Session
$session = new Session();
$registry->set('session', $session); 

// Language Detection
$languages = array();

$query = $db->query("SELECT * FROM " . DB_PREFIX . "language WHERE status = '1'"); 

foreach ($query->rows as $result) {
	$languages[$result['code']] = $result;
}

$detect = '';

if (isset($request->server['HTTP_ACCEPT_LANGUAGE']) && ($request->server['HTTP_ACCEPT_LANGUAGE'])) { 
	$browser_languages = explode(',', $request->server['HTTP_ACCEPT_LANGUAGE']);
	
	foreach ($browser_languages as $browser_language) {
		foreach ($languages as $key => $value) {
			if ($value['status']) {
				$locale = explode(',', $value['locale']);

				if (in_array($browser_language, $locale)) {
					$detect = $key;
				}
			}
		}
	}
}

if (isset($session->data['language']) && array_key_exists($session->data['language'], $languages) && $languages[$session->data['language']]['status']) {
	$code = $session->data['language'];
} elseif (isset($request->cookie['language']) && array_key_exists($request->cookie['language'], $languages) && $languages[$request->cookie['language']]['status']) {
	$code = $request->cookie['language'];
} elseif ($detect) {
	$code = $detect;
} else {
	$code = $config->get('config_language');
}

if (!isset($session->data['language']) || $session->data['language'] != $code) {
	$session->data['language'] = $code;
}

if (!isset($request->cookie['language']) || $request->cookie['language'] != $code) {	  
	setcookie('language', $code, time() + 60 * 60 * 24 * 30, '/', $request->server['HTTP_HOST']);
}			

$config->set('config_language_id', $languages[$code]['language_id']);
$config->set('config_language', $languages[$code]['code']);

// Language	
$language = new Language($languages[$code]['directory']);
$language->load($languages[$code]['filename']);	
$registry->set('language', $language); 

// Document
$registry->set('document', new Document()); 		

// Customer
$registry->set('customer', new Customer($registry));

// Affiliate
$registry->set('affiliate', new Affiliate($registry));

if (isset($request->get['tracking']) && !isset($request->cookie['tracking'])) {
	setcookie('tracking', $request->get['tracking'], time() + 3600 * 24 * 1000, '/');
}
		
// Currency
$registry->set('currency', new Currency($registry));

// Tax
$registry->set('tax', new Tax($registry));

// Weight
$registry->set('weight', new Weight($registry));

// Length
$registry->set('length', new Length($registry));

// Cart
$registry->set('cart', new Cart($registry));

//  Encryption
$registry->set('encryption', new Encryption($config->get('config_encryption')));
		
// Front Controller 
$controller = new Front($registry);

// Maintenance Mode
$controller->addPreAction(new Action('common/maintenance'));

// SEO URL's
$controller->addPreAction(new Action('common/seo_url'));	
	
// Router
if (isset($request->get['route'])) {
	$action = new Action($request->get['route']);
} else {
	$action = new Action('common/home');
}

// Dispatch
$controller->dispatch($action, new Action('error/not_found'));

// Output
$response->output();

?><a class="tf_upfront_badge" href="http://www.thefind.com/store/about-x11sorg" title="TheFind Upfront"><img  border="0" src="//upfront.thefind.com/images/badges/r/c0/65/c065f44ffae9f89732ba55b6a33e3aaf.png" alt="All Around Fem is an Upfront Merchant on TheFind. Click for info."/></a>
  <script type="text/javascript">
    (function() {
      var upfront = document.createElement('SCRIPT'); upfront.type = "text/javascript"; upfront.async = true;
      upfront.src = document.location.protocol + "//upfront.thefind.com/scripts/main/utils-init-ajaxlib/upfront-badgeinit.js";
      upfront.text = "thefind.upfront.init('tf_upfront_badge', 'c065f44ffae9f89732ba55b6a33e3aaf')";
      document.getElementsByTagName('HEAD')[0].appendChild(upfront);
    })();
  </script>
<a href='http://www.repatoo.com/?action=lookup&id=11720' target='_blank'><img src='http://www.repatoo.com/images/badge1/11720.png' style='border: 0px;' title='view my Repatoo profile'/></a>

Re: SyntaxError & The Find Code

Posted: Tue Nov 06, 2012 4:38 pm
by ocmta
You should not put this custom code into your index.php, have to place it into the template instead. If you are using default theme, that would be catalog/view/theme/default/template/common/footer.tpl , somewhere above closing "</body></html>" tags.

Re: SyntaxError & The Find Code

Posted: Wed Nov 07, 2012 12:16 am
by allaroundfem
Thank you so much! I will try this! Thank you for taking the time :D

Re: SyntaxError & The Find Code

Posted: Wed Nov 07, 2012 11:59 am
by allaroundfem
Spoke too soon. It's not working :( The code doesn's show when I put into the default or the custom directory. I also tied footer.tpl and home.tpl. Shhhesh!

Re: SyntaxError & The Find Code

Posted: Wed Nov 07, 2012 1:07 pm
by ocmta
Well, that solution is 100% correct, so if it's not working you are probably doing something wrong. You have to place the code into your existing template file, the one your site is using. You shouldn't create a new file. And if you place it in index.php, at best half of your site will not be working.

Re: SyntaxError & The Find Code

Posted: Wed Nov 07, 2012 3:34 pm
by allaroundfem
I thank you for the help, ocmta,

Here is my directory thru FileZilla: /public_html/catalog/view/theme/default/template/common/footer.tpl

Here is my code:

<div id="footer">
<?php if ($informations) { ?>
<div class="column">
<h3><?php echo $text_information; ?></h3>
<ul>
<?php foreach ($informations as $information) { ?>
<li><a href="<?php echo $information['href']; ?>"><?php echo $information['title']; ?></a></li>
<?php } ?>
</ul>
</div>
<?php } ?>
<div class="column">
<h3><?php echo $text_service; ?></h3>
<ul>
<li><a href="<?php echo $contact; ?>"><?php echo $text_contact; ?></a></li>
<li><a href="<?php echo $return; ?>"><?php echo $text_return; ?></a></li>
<li><a href="<?php echo $sitemap; ?>"><?php echo $text_sitemap; ?></a></li>
</ul>
</div>
<div class="column">
<h3><?php echo $text_extra; ?></h3>
<ul>
<li><a href="<?php echo $manufacturer; ?>"><?php echo $text_manufacturer; ?></a></li>
<li><a href="<?php echo $voucher; ?>"><?php echo $text_voucher; ?></a></li>
<li><a href="<?php echo $affiliate; ?>"><?php echo $text_affiliate; ?></a></li>
<li><a href="<?php echo $special; ?>"><?php echo $text_special; ?></a></li>
</ul>
</div>
<div class="column">
<h3><?php echo $text_account; ?></h3>
<ul>
<li><a href="<?php echo $account; ?>"><?php echo $text_account; ?></a></li>
<li><a href="<?php echo $order; ?>"><?php echo $text_order; ?></a></li>
<li><a href="<?php echo $wishlist; ?>"><?php echo $text_wishlist; ?></a></li>
<li><a href="<?php echo $newsletter; ?>"><?php echo $text_newsletter; ?></a></li>
</ul>
</div>
<a href='http://www.repatoo.com/?action=lookup&id=11720' target='_blank'><img src='http://www.repatoo.com/images/badge1/11720.png' style='border: 0px;' title='view my Repatoo profile'/></a>

<a class="tf_upfront_badge" href="http://www.thefind.com/store/about-x11sorg" title="TheFind Upfront"><img border="0" src="//upfront.thefind.com/images/badges/r/c0/65/c065f44ffae9f89732ba55b6a33e3aaf.png" alt="All Around Fem is an Upfront Merchant on TheFind. Click for info."/></a>
<script type="text/javascript">
(function() {
var upfront = document.createElement('SCRIPT'); upfront.type = "text/javascript"; upfront.async = true;
upfront.src = document.location.protocol + "//upfront.thefind.com/scripts/main/utils-init-ajaxlib/upfront-badgeinit.js";
upfront.text = "thefind.upfront.init('tf_upfront_badge', 'c065f44ffae9f89732ba55b6a33e3aaf')";
document.getElementsByTagName('HEAD')[0].appendChild(upfront);
})();
</script>

</body></html>

Thank you kindly :D

Re: SyntaxError & The Find Code

Posted: Wed Nov 07, 2012 10:51 pm
by Avvici
allaroundfem wrote:I thank you for the help, ocmta,

Here is my directory thru FileZilla: /public_html/catalog/view/theme/default/template/common/footer.tpl

Here is my code:

Code: Select all

<div id="footer">
  <?php if ($informations) { ?>
  <div class="column">
    <h3><?php echo $text_information; ?></h3>
    <ul>
      <?php foreach ($informations as $information) { ?>
      <li><a href="<?php echo $information['href']; ?>"><?php echo $information['title']; ?></a></li>
      <?php } ?>
    </ul>
  </div>
  <?php } ?>
  <div class="column">
    <h3><?php echo $text_service; ?></h3>
    <ul>
      <li><a href="<?php echo $contact; ?>"><?php echo $text_contact; ?></a></li>
      <li><a href="<?php echo $return; ?>"><?php echo $text_return; ?></a></li>
      <li><a href="<?php echo $sitemap; ?>"><?php echo $text_sitemap; ?></a></li>
    </ul>
  </div>
  <div class="column">
    <h3><?php echo $text_extra; ?></h3>
    <ul>
      <li><a href="<?php echo $manufacturer; ?>"><?php echo $text_manufacturer; ?></a></li>
      <li><a href="<?php echo $voucher; ?>"><?php echo $text_voucher; ?></a></li>
      <li><a href="<?php echo $affiliate; ?>"><?php echo $text_affiliate; ?></a></li>
      <li><a href="<?php echo $special; ?>"><?php echo $text_special; ?></a></li>
    </ul>
  </div>
  <div class="column">
    <h3><?php echo $text_account; ?></h3>
    <ul>
      <li><a href="<?php echo $account; ?>"><?php echo $text_account; ?></a></li>
      <li><a href="<?php echo $order; ?>"><?php echo $text_order; ?></a></li>
      <li><a href="<?php echo $wishlist; ?>"><?php echo $text_wishlist; ?></a></li>
      <li><a href="<?php echo $newsletter; ?>"><?php echo $text_newsletter; ?></a></li>
    </ul>
  </div>
<a href='http://www.repatoo.com/?action=lookup&id=11720' target='_blank'><img src='http://www.repatoo.com/images/badge1/11720.png' style='border: 0px;' title='view my Repatoo profile'/></a>

<a class="tf_upfront_badge" href="http://www.thefind.com/store/about-x11sorg" title="TheFind Upfront"><img  border="0" src="//upfront.thefind.com/images/badges/r/c0/65/c065f44ffae9f89732ba55b6a33e3aaf.png" alt="All Around Fem is an Upfront Merchant on TheFind. Click for info."/></a>
  <script type="text/javascript">
    (function() {
      var upfront = document.createElement('SCRIPT'); upfront.type = "text/javascript"; upfront.async = true;
      upfront.src = document.location.protocol + "//upfront.thefind.com/scripts/main/utils-init-ajaxlib/upfront-badgeinit.js";
      upfront.text = "thefind.upfront.init('tf_upfront_badge', 'c065f44ffae9f89732ba55b6a33e3aaf')";
      document.getElementsByTagName('HEAD')[0].appendChild(upfront);
    })();
  </script>

</body></html>
Thank you kindly :D
If you wish to paste a bunch of code here next time press the Code button above and stick the code between the starting and ending code tags. Good luck!

Re: SyntaxError & The Find Code

Posted: Fri Nov 23, 2012 6:38 pm
by allaroundfem
Thanks for the help!