Jump to content

Unexpected T_as error


acctman

Recommended Posts

can someone assist me with the code below? Unexpected T_as error

 

the countries.php file

$countries['US'] = array(name => 'United States');
$countries['AF'] = array(name => 'Afghanistan');

 

code..

if ($en['mm_country'] != US || CA) {
global $countries; include 'modules/members/countries.php';
$countries as $key => $value;
$key = $en['mm_country'];
$en['mm_coname'] = htmlentities($value['name'],ENT_QUOTES);
echo $en['mm_coname'];
}

Link to comment
Share on other sites

Put quotes around name.

 

$countries['US'] = array('name' => 'United States');
$countries['AF'] = array('name' => 'Afghanistan');

 

this is already formated in a file, and works fine without the quotes when used elsewhere on the site.

Link to comment
Share on other sites

Then use normal array access

$key = "US";
$country = $countries[$key];

 

when i do that the result is just Array. the code needs to be something like this, but i'm not sure how to code it correctly.

 

if ($en['mm_country'] != US) || ($en['mm_country'] != CA) {
global $countries; include 'modules/members/countries.php';
$key = $en['mm_country'];
$country = $countries(htmlentities($key['name'],ENT_QUOTES));
echo $country;
}

 

Link to comment
Share on other sites

What does "code it correctly" mean? You haven't told us what you want.

oh sorry i thought i did, i want to connect to countries.php and grab the country name. $en['mm_country'] holds the $key abbervation of the country. so if AF is supplied then when I echo $country the return value should be Afghanistan. also when grabbing the country name htmlentities needs to be used to strip the quotes

 

 

$countries['US'] = array(name => 'United States');

$countries['AF'] = array(name => 'Afghanistan');

Link to comment
Share on other sites

$countries(htmlentities($key['name'],ENT_QUOTES));

^ $countries is an array. Use brackets, not parentheses.

 

$country = htmlentities($countries[$key['name']], ENT_QUOTES);

 

Like that?

nothing was returned, no error.

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.