-1

Heres whats going on, I want to make a multilingual websites Array to string conversion error:Notice: Array to string conversion in C:\wamp\www\choose language\language.php on line 12

<form action="language_switcher.php" method="post">
<select name="lang">
    <option value="en"<?php if( $_COOKIE["language"] == "en" ) { echo " selected"; } ?>>English</option>
    <option value="fr"<?php if( $_COOKIE["language"] == "fr" ) { echo " selected"; } ?>>Français</option>
    <option value="de"<?php if( $_COOKIE["language"] == "de" ) { echo " selected"; } ?>>Deutsch</option>
    <option value="it"<?php if( $_COOKIE["language"] == "it" ) { echo " selected"; } ?>>Italiano</option>

</select>
<input type="submit" value="Select Language">
</form>

<p>Language: <?php if( isset( $_COOKIE['language'] ) ) { echo $_COOKIE['language']; } else { echo "<em>not set</em>"; } ?></p>
Cedricle
  • 95
  • 1
  • 5

1 Answers1

0

most likely your

$_COOKIE["language"]

is NOT a string like "en" but rather an array like array($code=>"en", $name=>"english"). you need to inspect that value first. echo it, print_r it or var_dump it.

add

<?php var_dump($_COOKIE["language"]); ?> 

to the top of your page or anywhere.

AwokeKnowing
  • 7,728
  • 9
  • 36
  • 47